1. 程式人生 > >js(jquery)綁定點擊事件

js(jquery)綁定點擊事件

bmi ont 三種 false -s element mil 綁定 fun

<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*/ } );

js(jquery)綁定點擊事件