我有一個標籤內的鏈接。問題是,當用戶在閱讀條款後點擊「後退」時,複選框未被選中,因爲當他們點擊鏈接時,他們也同時取消選中該框,因爲鏈接位於標籤內。如何防止點擊標籤內鏈接時的複選框檢查
<input type="checkbox" id="terms" name="terms" checked="checked" />
<label for="terms">I agree to be bound by the <a href="/terms">Terms</a></label>
如何防止單擊鏈接時檢查複選框?試圖在標籤上點擊event.preventDefault()
,但這並不妨礙複選框被選中/取消選中。
我可以從標籤內取出鏈接(這意味着更多的CSS樣式)。但現在我很好奇上述是否可能。
就我而言,我不得不更換`onclick`,而是`onmousedown` – 2015-08-20 07:38:08