Finding the name of method in jquery -
i trying find method names in html code. find method name in 'onclick' attribute , make operations.
this current code:
<div class="button" style="width: 60px; float: right;" onclick="closemodaldialog('dialogattachmentmodal');">blabla</div>
i want write jquery this:
$('closemodaldialog').attr('id','btnclosemodal');
and want show this:
<div class="button" id="btnclosemodal" style="width: 60px; float: right;" onclick="closemodaldialog('dialogattachmentmodal');">blabla</div>
i know, selector must id or class. want add attribute this.(because have more 'button' class , want add one) possible? how can succeed? thx in advance , sorry language.
you can use 'attribute begins selector' this:
$('[onclick^="closemodaldialog"]').prop('id', 'btnclosemodal');
note it's better practice use prop()
set domelement properties, , if there multiple elements have onclick
attribute end duplicate id
value - render page invalid.
Comments
Post a Comment