Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check radio button whose value = $ programmatically

There is a radio button group define as below:

<input type="radio" name="type0" value="$">$<input type="radio" name="type0" value="%">%

Need to check the first radio button whose value = $.

The problem is the below code doesn't accomplish this. Need some way of escaping $

$('input[type=radio][value=$]').attr('checked','checked');
like image 595
deostroll Avatar asked Dec 16 '22 05:12

deostroll


2 Answers

$('input[type=radio][value="$"]').first().attr('checked','checked');
like image 199
Alex Avatar answered Jan 28 '23 12:01

Alex


this works for me, enclose the selector in double quotes and the attribute selector in single ones

$("input[type=radio][value='$']").attr('checked','checked');

http://jsfiddle.net/BuvKT/

like image 20
Rafay Avatar answered Jan 28 '23 11:01

Rafay