Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
クリック関数の署名を変更して、イベント引数を受け入れ、以下を使用しpreventDefaultます。
preventDefault
$("a[href='#']").bind("click", function (e) { e.preventDefault(); }); $(".clickable").bind("click", function(){alert("It works!");})
これが実用的なフィドルです。
何かが泡立つのを防ぐために、私は常にこれに従います:
$('myAnchor').live("click", function(e) { e.preventDefault(); e.stopPropagation(); //or if you want to stop all handlers e.stopImmediatePropagation(); //code here //for IE etc. return false; });