Wrap Checkboxes with jQuery
Mon Aug 05 2024 05:53:12 GMT+0000 (Coordinated Universal Time)
Saved by
[deleted user]
$(document).ready(function() {
// Select the div with the class 'radiobuttonlist'
$('.radiobuttonlist').each(function() {
// Find each input within the radiobuttonlist div
$(this).find('input[type="radio"]').each(function() {
// Get the current input
var $input = $(this);
// Get the corresponding label for the current input
var $label = $('label[for="' + $input.attr('id') + '"]');
// Create a new div with class 'radiowp'
var $wrapper = $('<div class="radiowp"></div>');
// Wrap the input and label with the new div
$input.add($label).wrapAll($wrapper);
});
});
});
content_copyCOPY
https://chatgpt.com/c/0bed8330-b7d0-4d76-9f9b-94e81c012d36
Comments