Monday, 15 June 2015

jQuery and doing event always once -



jQuery and doing event always once -

there couple buttons:

<button id="bid1">button 1</button> <button id="bid2">button 2</button>

and i'am trying set event sec button

$("#bid1").click(function() { $("#bid2").click(function() { alert("test"); }); });

if press first button several times , press sec button. how set sec button click-event alerts 1 time (not number of times pressed first button)? give thanks you!

the way writing click event handlers wrong. binding click handler within other not right, though works you.

use .one() sec button.

$("#bid1").click(function() { }); $("#bid2").one('click',function() { alert("test"); });

jquery

No comments:

Post a Comment