Skip to content Skip to sidebar Skip to footer

Use Li To Select Radio Input?

I am using a payment button generator for a specific selection of items that creates a pre-made radio list of prices. When you select the amount/item you want, you then click 'con

Solution 1:

If JQuery is allowed:

$('li').click(function() {
$(':radio[data-price-id="'+$(this).data('level')+'"]').prop('checked', true);
});

Just give list items appropriate attributes:

<liid="item1"data-level="1"><div>my content</div></li><liid="item2"data-level="2"><div>my content</div></li>

EDIT: If you can't change HTML structure, try with this:

$('li').click(function() {
    index=$(this).index();
$(':radio').eq(index).prop('checked', true);
});

Post a Comment for "Use Li To Select Radio Input?"