我有一个这样的简单列表:
<ul id="large_box_custom_list">
<li id="8" class="large_box">Item 1</li>
<li id="13" class="large_box">Item 2</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
然后我有一个像这样的jQuery函数:
$(function() {
$('li.large_box').css('cursor', 'pointer')
.click(function() {
var show_id = $(this).val();
alert(show_id);
});
});
Run Code Online (Sandbox Code Playgroud)
当我单击列表项时,当我期望值为8或13时,我的alery显示值为0.
Draggable可以在这里工作,但是当我将DIV拖到可放置区域时,警报功能不会被触发.我确定这是愚蠢的事,但也许有人可以阻止我把我的头撞到墙上,我做得对不对?
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
<title></title>
</head>
<body>
<script>
$(function() {
$( ".draggable" ).draggable();
$( ".droppable" ).droppable({
drop: function(event, ui) {
alert('dropped');
}
});
});
</script>
<div id=10 class="draggable">one</div>
<div id="trash" class="droppable"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)