[英]Jquery Method not found
I'm changing the following script in order to work with jQuery: http://www.w3schools.com/html/html5_draganddrop.asp . 我正在更改以下脚本以使用jQuery: http : //www.w3schools.com/html/html5_draganddrop.asp 。
drag = function(ev) {
console.log("started drag", ev.target);
console.log('$(ev.target).parent()[0]', $(ev.target).parent()[0]);
console.log(' $(ev.target).parent()[0].attr(\'id\')', $(ev.target).parent()[0].attr('id'));
}
Can someone explain why I get an Uncaught TypeError: undefined is not a function in the last log? 有人可以解释为什么我得到Uncaught TypeError:undefined不是最后一个日志中的函数吗? (attr method) (attr方法)
Try, 尝试,
$(ev.target).parent().attr('id')
The error is raising because .attr()
is not a native javascript function. 由于.attr()
不是本机javascript函数,因此出现错误。
And by the way, it is the time for you to read www.w3fools.com 顺便说一句,这是您阅读www.w3fools.com的时候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.