Wrap the insides of Buttons


/ Published in: jQuery
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.