首先,對不起我的英文不好。用onClick複選框覆蓋parrents onClick事件?
我在製作優惠券網站,並且無法選擇和取消選擇優惠券。每張優惠券都位於一個DIV「盒子」中,其中有一個複選框。
我在DIV框上做了一個onClick函數(所以用戶可以通過點擊DIV框內的任何東西來選擇優惠券,現在我需要的是,當用戶想要取消選擇優惠券時(通過點擊複選框在DIV框中),我需要'覆蓋'DIV的onClick函數(執行onClick事件的checkbox,而不是DIV的onClick事件)
我知道每個人都喜歡一些代碼作爲例子,但問題/問題很簡單,我不認爲你需要所有的事件/功能我un'useless代碼:)
謝謝:)
代碼樣本幾乎總是幫助更容易。話雖如此,你有沒有考慮過在複選框上使用jQuery的stopPropagation? http://api.jquery.com/event.stopPropagation/ – j08691 2012-01-14 22:40:27