Jennifer Anthony
Jennifer Anthony

Reputation: 2277

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/

$('.iu').click(function() {
    if(alert() == true){
        alert('ok')
    }else{
        alert('no')
    }
});

Upvotes: 0

Views: 88

Answers (1)

RoccoC5
RoccoC5

Reputation: 4213

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/

Upvotes: 5

Related Questions