The value of handover li.html
The code copy is as follows:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Swap the value of Li</title>
<script type="text/javascript">
window.onload= function() {
var lis = document.getElementById("ulList").childNodes;
for (var i = 0; i < lis.length; i++) {
var myli = lis[i];
//Judge whether it is a tag
if (myli.nodeType == 1) {
//Switch location with a li below
myli.onclick = function() {
if (this.nextElementSibling) {
var nextli = this.nextElementSibling;//This can only be used here, not myli
document.getElementById("ulList").insertBefore(nextli, this);
}
};
}
}
}
</script>
</head>
<body>
<ul id="ulList">
<li>Beijing</li>
<li>Shanxi</li>
<li>Shanghai</li>
<li>Tianjin</li>
<li>Henan</li>
</ul>
</body>
</html>