Can someone tell me what is wrong with this javascript ?
$("#parent-project").attr("data-id").click(function(){
//some code...
}
The console output is:
Cannot read property 'click' of undefined
Using attr() will return a string value to which a click handler cannot be attached. I imagine you wanted
$("#parent-project[data-id]").click(function(){
//some code...
}
In which []
is notation for attribute
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.