Переключение между input radio
Привет Всем! Ребята помогите решить задачу / уже голову сломал
В общем есть список radio input - тов / При переключении по ним открываются разные 4 фотки / На js смог реализовать задачу , а вот на jquery не догоняю. Вот код на чистом js : function west() { var age = document.getElementsByName('age1'); // input var images = document.querySelectorAll('img'); // tag img for (var i = 0; i < age.length; i++) { if (age[i].checked) { images[i].style.display = 'block'; } else { images[i].style.display = 'none'; } } } Кто может перевести на jquery буду благодарен? |
<html> <head> <meta charset="utf-8"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <style> div { display: none; } .show { display: block; } </style> </head> <script type="text/javascript"> $(function() { var bx = $('div'), bt = $('input:radio').change(function() { bx.filter('.show') .removeClass('show') .end() .eq(this.value) .addClass('show'); }); }); </script> </head> <body> <input type="radio" name="b" value="0" checked="" /> <input type="radio" name="b" value="1" /> <input type="radio" name="b" value="2" /> <input type="radio" name="b" value="3" /> <div class="show">111</div> <div>222</div> <div>333</div> <div>444</div> </body> </html> Все это можно организовать и на CSS. |
Спасибо бро)
|
Часовой пояс GMT +3, время: 06:38. |