我有这个函数,但它给了我函数语句 require name onStop function
<script type="text/javascript">
jQuery( function($) {
$('#Hnav, #Nnav').NestedSortable(
{
accept: 'sort',
noNestingClass: "no-children",
helperclass: 'helper',
autoScroll: true,
onChange: function(serialized) {
onStop : function(){
$('#output').html($(this).id);
},
nestingPxSpace : '0'
}
);
});
</script>
最佳答案
在此上下文中,this
指的是发生 onStop
事件的 DOM 元素。 DOM 元素不是 jQuery 对象。
jQuery $(this)
对象没有 id
属性,而 DOM 元素有。因此,请使用:
$('#output').html(this.id);
或:
$('#output').html($(this).attr("id"));
并且不要忘记在 onChange
处理函数中关闭括号。
关于javascript - 函数语句需要 JQuery 中的名称错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11242212/