Показать сообщение отдельно
  #2 (permalink)  
Старый 05.07.2015, 03:27
Профессор
Отправить личное сообщение для Decode Посмотреть профиль Найти все сообщения от Decode
 
Регистрация: 31.01.2015
Сообщений: 576

<!doctype html>
<html>
<head>
  <meta charset="utf-8" />
  <title></title>
</head>
<body>
  <div class="block">
    <input id="one" type="checkbox" />
    <a href="#" id="one">Один</a>

    <input id="two" type="checkbox" />
    <a href="#" id="two">Два</a>

    <input id="three" type="checkbox" />
    <a href="#" id="three">Три</a>
  </div>


  <script>
    document.querySelector('.block').onclick = function(e) {
      e.preventDefault();

      var target, id, elem;

      target = e.target;
      if(target.nodeName != 'A') return;

      id = target.getAttribute('id');
      if(!id) return;

      elem = document.getElementById(id);
      elem.checked = (elem.checked) ? false : true;
    };
  </script>

</body>
</html>
Ответить с цитированием