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

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -