Reputation: 31
Hy can someone tell my ho to rename the class fb_connect to fb_connect2 with javascript?
<fieldset id="fieldset-ezformstep1">
<h3 class="legend">
<a href="#null" class="fb_connect">Connect to facebook</a>
</h3>
</fieldset>
this should be the result
<fieldset id="fieldset-ezformstep1">
<h3 class="legend">
<a href="#null" class="fb_connect2">Connect to facebook</a>
</h3>
</fieldset>
thanks
Upvotes: 3
Views: 130
Reputation: 642
If you would like to do it without jquery:
var elems = document.getElementsByClassName('fb_connect');
for (var i = 0; i < elems.length; i++) {
elems[i].className = elems[i].className.replace(/\bfb_connect\b/, 'fb_connect2');
}
Upvotes: 0
Reputation: 19672
If you are using jQuery (guessing by the tag), this is a possibility:
$("#fieldset-ezformstep1 > h3.legend > a.fb_connect").attr("class","fb_connect2");
Don't forget to wait until after the DOM is ready to do so.
Upvotes: 0
Reputation: 74420
You can use this:
$(window).load(function(){ // or document ready but i suspect you need to wait for the window loaded event
$('.fb_connect').toggleClass('fb_connect fb_connect2');
});
Upvotes: 2