我正在寫一個函數:jQuery的的onclick防止defaut行爲
(function($) {
$.fn.openBox = function(theId) {
// do something
};
})(jQuery);
和幾個環節叫我的功能是這樣的:
<a href="#" onclick="$(this).openBox('#theBoxId');">Open the box !</a>
我知道我可以防止回假默認行爲:
<a href="#" onclick="$(this).openBox('#theBoxId'); return false">Open the box !</a>
但是我希望把它在我的jQuery函數... 我和event.target測試,但它似乎並不工作...
感謝Guffa! 數據屬性正常工作! – user1355748 2012-04-25 09:59:59