Vote count:
0
I tried to move the list item when click on them, and I followed the code of this accepted answer. And it did work on JSfiddle, see here. But when I move this code into html file, it doesn't work. The content of the whole file is listed below.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test the jQurey cycle</title>
<script src="http://ift.tt/1mWWrGH"></script>
<script type="text/javascript">
$('.simple li').click(function() {
var $this = $(this);
$this.insertBefore($this.siblings('.simple li:nth-child(1)'));
});
</script>
<style type="text/css">
.for-list li{
float:left; width:60px;
}
.for-list{
list-style-type:none;
}
</style>
</head>
<body>
<ul class="simple for-list">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ul>
</body>
</html>
I couldn't find out What's wrong with this code?
asked 43 secs ago
jquery doesn't work when move list item
Aucun commentaire:
Enregistrer un commentaire