javascript - All elements of same name, added dynamically, with on click handler all fire when referred by class name but different data-attribute -


lets add element dom using jquery, onclick handler class=“justice” , data-attribute = “1", , add element same class name, different data-attribute = “2”, lets gave both elements different values. should able call $(‘.justice[data-attribute=‘2’]“).val, different $(‘.justice[data-attribute=‘1’]“).val right?

yes should. in example though, did not use period when selecting class.

also, not forget parentheses following val call per jquery spec.

$(‘justice[data-attribute=‘1’]“).val  

vs.

$(".justice[data-attribute='1']").val()  

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -