Wednesday, January 25, 2012

[jQuery] Change Element Class Name

Example:
<div>
  <span class=”old_class”>hello there!</span>
</div>

Change the class using jQuery:
$('div span').removeClass('old_class').addClass('new_class');

Result:
<div>
  <span class="new_class">hello there!</span>
</div>

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...