Not work my function after click?
I not know why not work following code for my function(alert()
) and is run my function(alert()
) after tow times click on button, did you can guide me?
Demo:(Here see my full code) http://jsfiddle.net/pRXQ7/1/
开发者_JS百科$('.iu').click(function() {
if(alert() == true){
alert('ok')
}else{
alert('no')
}
});
By naming your function alert
, you've effectively overridden the native javascript alert
function. Name it something else.
Also, in your alert
function, you are referencing this
. In the scope of the function, this
points to the document object, not the element which was clicked. Try passing the element instance to your function from the click event handler.
See http://jsfiddle.net/pRXQ7/15/
精彩评论