KumbaThought KumbaThought - 7 months ago 12
Javascript Question

Drupal / jQuery / CSS :: Wrap radio button label in span tag?

When a radio button is rendered in Drupal, it comes out like:

<label class="form-radio" for="sample">
<input type="radio" name="samp" value="1" />Sample
</label>


I've been looking at theming functions (namely, theme_radios and theme_form_element, but can't figure out how to render the output like

<label class="form-radio" for="sample">Sample</label>
<input type="radio" name="samp" value="1" />.


Can someone point me in the right direction? Been combing the forums but haven't found anything to help... I'd even be happy with a jquery solution...

Answer

You can try this after the page is loaded

$(function(){
  $("lable.form-radio").each(function(){
     $(this).after($(this).find("input[name=samp]"));
  });
});
Comments