binding - JQuery bind function to multiple objects -
how can edit code below bind function both mylink
, mybutton
.
if (section === x) { mybutton = $("#a"); mylink = $("#b"); } else { mybutton = $("#c"); mylink = $("#d"); } mylink.click(function(e) { e.preventdefault(); showmydialog(); });
if (section === x) { $("#a,#b").click(onclick); } else { $("#c,#d").click(onclick); } function onclick(e) { e.preventdefault(); showmydialog(); });
Comments
Post a Comment