Use jQuery to apply styling to all instances of clicked element -
what i'm aiming jquery @ element i've clicked on (for example p or li tag), apply styling instances of element (so p tags on page).
this code far, applies styling single element has been clicked on.
$("article *", document.body).click(function (e) { e.stoppropagation(); selectedelement = $(this); $(selectedelement).css("border", "1px dotted #333") });
would appreciate or advice!
$('article *',document.body).click( function(e){ e.stoppropagation(); var selectedelement = this.tagname; $(selectedelement).css('border','1px dotted #333'); } );
demo @ js bin, albeit i've used universal selector (since posted couple of lists (one ol
other ul
).
above code edited in response comments @peter ajtai, , linked js bin demo up-dated reflect change:
why run around block once before @ tagname? how var selectedelement = this.tagname;. it's e.stoppropagation(), since you're calling method.
Comments
Post a Comment