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
if ($("#parent-project[data-id]") != ("#open_project[data-id]")) { but only compare the data-idif ($("#parent-project").attr("data-id") != $("#open_project").attr("[data-id]"))
.attr("data-id")returns a string, which has noclickmethoddata-idis selected$("#parent-project[data-id="+myVar+"]").click(function(){ // code }