javascript - Variation dropdowns into radio buttons -
i trying convert dropdown radio buttons on fly using jquery, here code
jquery(document).ready(function($) { $('select#pa_size option[value=' + $choice + ']').attr('selected', true).parent().trigger('change'); });
this code me radio button. cant work add-to-cart option. please click add-to-cart link see direct page.
jquery(document).ready(function($){ //get exising select options $('select#pa_size').each(function(i, select){ var $select = $(select); $select.find('option').each(function(j, option){ var $option = $(option); // create radio: var $radio = $('<input type="radio" />'); // set name , value: $radio.attr('name', $select.attr('name')).attr('value', $option.val()); // set checked if option selected if ($option.attr('selected')) $radio.attr('checked', 'checked'); // insert radio before select box: $select.before($radio); // insert label: $select.before( $("<label />").attr('for', $select.attr('name')).text($option.text()) ); // insert <br />: $select.before("<br/>"); }); $select.remove(); }); $('.single_variation_wrap').css('display','block');
});
// latest code. same problem
Comments
Post a Comment