如果复选框被选中,只允许链接被点击
Only allow a link to be clickable if checkbox is selected
我试图设置一个按钮/链接,只有在选中复选框时才能单击。到目前为止我的代码是
<form>
<input type="checkbox" name="agreeCheckbox" value="agreeCheckbox">By clicking this you agree that you are adding a subscription/recurring product to your order<br>
</form>
<a href="exmaple.com">This link is only clickable if checkbox is checked</a>
我假设我将不得不在javascript中这样做,虽然我是一个初学者,当它涉及到javascript。由于
这段代码向元素添加了一些id
属性,以便为Javascript提供一些钩子。它隐藏并阻止锚的默认动作,直到复选框被点击。