js(jquery)绑定点击事件

<button type="submit" id="test">test</button>

第一种

$("#test").click(function(event){
/* Act on the event */});

第二种

document.getElementById('#foo').addEventListener('click', function() {
/* Act on the event */}, false);

第三种

html

     <button type="submit" id="test" onclick="test()">test</button>

js

     function test(){/* Act on the event */}

第四种

$('#test').bind('click', function() {/* Act on the event */ });

第五种

$( "#test" ).on( "click", function() {/* Act on the event*/ } ); 

posted @ 2017-12-12 22:41  IT文艺女  阅读(353)  评论(0编辑  收藏  举报