如何在单击时将href设置为复选框

How to set href to a checkbox on click?

本文关键字:href 设置 复选框 单击      更新时间:2023-09-26

1.如何在单击时将href设置为复选框

<a href="/Demo/sense/show/4">
  <input type="checkbox" />Yes
</a>
  <a href="/Demo/sense/list">
      <input type="checkbox" />NO
    </a>

但当我选中复选框时。。它不会转到另一页。。

2.如何在点击YES文本而不是YES复选框时设置复选框请帮帮我。。Thanx

<input type="checkbox" onclick='window.location.assign("/Demo/sense/show/4")'/>Yes

也许是这样的?

<input id="cb" type="checkbox" onchange="window.location.href='http://google.com/'">

也许还有一个标签:

<label for="cb">Yes</label>

只需简化代码即可:

<input type="checkbox" id="chk1" />Yes
  <input type="checkbox" id="chk2" />NO
  <script type="text/javascript">
      $(document).ready(function(){
          $('#chk1').click(function(){
          window.location='http://www.yahoo.com'; // link of your desired page.  
          });
      });
  </script>