Выделить radio, удалив все остальные.
По отдельности все работает, но вместе работать не хочет.
<script> $(function() { $("#test").click(function(){ $(".radioId").removeAttr("checked"); $("#radioId"+$(this).attr('data-id')).attr('checked', 'checked'); }); }); </script> <input id="radioId318" class="radioId" type="radio" value="318" name="radioId"> <input id="radioId319" class="radioId" type="radio" value="319" name="radioId"> <input id="radioId320" class="radioId" type="radio" value="320" name="radioId"> <input type="submit" id="test" data-id="319" /> |
light,
:-? <!DOCTYPE HTML> <html> <head> <title>Untitled</title> <meta charset="utf-8"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script> $(function() { $("#test").click(function(){ $(".radioId").prop("checked", false); $("#radioId"+$(this).data('id')).prop("checked", true); }); }); </script> </head> <body> <input id="radioId318" class="radioId" type="radio" value="318" name="radioId"> <input id="radioId319" class="radioId" type="radio" value="319" name="radioId"> <input id="radioId320" class="radioId" type="radio" value="320" name="radioId"> <input type="submit" id="test" data-id="319" /> </body> </html> |
рони,
Спасибо) очень помогли. |
Часовой пояс GMT +3, время: 20:09. |