There is a list with div blocks. In these blocks there are radio buttons that are responsible for selecting the block. I want to make a choice of a particular radio programmatically, tobish to put the checked attribute. I do it like this: $('div#1').find('input[type=radio][name=offers]').attr('checked', true) . In the element itself (html) the attribute appeared, but visually it is not shown that it was selected. What could be the problem?
- Add a working code example: js, css, html to the question - Grundy
|
2 answers
Use prop :
$('div#1').find('input[type=radio][name=offers]').prop('checked', true); |
$('div#1').find('input[type=radio][name=offers]').attr('checked', 'checked'); - What does this code do and how does it relate to the question asked? - Grundy
- put this $ ('div # 1'). find ('input [type = radio] [name = offers]'). attr ('checked', 'checked'); in the place $ ('div # 1'). find ('input [type = radio] [name = offers]'). attr ('checked', true) - Taron
- oneComments are not a place for code, add everything you need in response, and do not forget to add a description of what exactly your piece of code does - Grundy
|