Posted By

dougunderscorenelson on 04/28/09


jquery button span swap

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Wrap the insides of Buttons

 / Published in: jQuery

Quick script to find button elements (and elements with the "button" class) and wrap their innards in spans. Good for making rounded-corner buttons.

  1. $("button, .button").each(function() {
  2. var hasSpan = $(this).find("span")[0];
  3. if (hasSpan = "undefined") {
  4. $(this).wrapInner("<span></span>");
  5. }
  6. });

Report this snippet  

You need to login to post a comment.