Search code examples
jqueryinputradio-buttonjquery-selectorsaddition

jQuery add empty label tags next to every radio button or checkbox


I need a simple jQuery code that will add an empty label tag next to every radio button or checkbox

So for example:

$('input[type="radio"]').next().add("<label for="radio"></label>");
$('input[type="checkbox"]').next().add("<label for="checkbox"></label>");

How can I accomplish this?

Thanks.


Solution

  • $('input[type="radio"]').after("<label for='radio'></label>");
    $('input[type="checkbox"]').after("<label for='checkbox'></label>");