问题很简单,但我做不到......在这里我的代码:
jQuery('nav').on('click', 'a', function(event){
console.log(jQuery(this));
});
答案 0 :(得分:1)
nav
必须是类或ID,导航似乎不是标准标记
如果是类名
jQuery('.nav').on('click', 'a', function(event){
console.log(jQuery(this));
});
如果是Id
jQuery('#nav').on('click', 'a', function(event){
console.log(jQuery(this));
});
这里有现场演示:http://jsfiddle.net/netme/hx8HR/
答案 1 :(得分:1)
你的代码看起来很好....但我认为你错过了document.ready
函数
试试这个
jQuery(function(){ //ready function
jQuery('nav').on('click', 'a', function(event){
console.log(jQuery(this));
});
});