Monday, 15 September 2014

Button to change color when active with JQuery -



Button to change color when active with JQuery -

when press button nil happens, color same.

html:

<div class="fadebox leadstyle-container"> <p class="button" data-lead-id="button-id"> <a href="http://..." class="btn leadstyle-link" target="_blank" style="display: block;">register live online event w/ mark allen &amp; dave scott</a> </p> </div>

js:

$(document).ready(function(){ $(".btn leadstyle-link").click(function(){ $(this).css("background-color","#0f6832"); }); });

i tried selecting classes in div , children jquery no avail. can provide css too, if needed.

your selector isnt right. element has 2 classes btn , leadstyle-link. :

$(".btn").click(function(){ .... }

or

$(".leadstyle-link").click(function(){ .... }

or archer has mentioned, utilize intersection. check out example have worked out in jsfiddle. seems working fine.

jquery

No comments:

Post a Comment