Home » jQuery » Changing The Value Of a Div on Click of a Button From a Set of Radio Button Using jQuery

Changing The Value Of a Div on Click of a Button From a Set of Radio Button Using jQuery

Changing the value of a div on click of a button from a set of radio button using jquery:
<div>
<ul>
<li><input type=”radio” value=”radio1″ name=”demoChangeFunc” /></li>
<li><input type=”radio” value=”radio2″ name=”demoChangeFunc” /></li>
<li><input type=”radio” value=”radio3″ name=”demoChangeFunc” /></li>
<li><input type=”radio” value=”radio4″ name=”demoChangeFunc” /></li>
</ul>
<div></div>
</div>

$(‘.radio-button-demo input’).each(function() {
if($(this).attr(‘checked’,’checked’)){
$(‘.list-value’).text($(this).attr(‘value’));
}
})

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.