javascript - How to onclick outside an input element which is inside a div? -


It is probably easy, but the way I click outside the text box to make some alert in JavaScript, it I can not think of anything to find when I click to do nothing inside the text. The input text is inside the div element.

So, suppose my html is like bellow:

    

How to change it?

Thank you very much!

You shoud using this condition.

It is often useful to compare event.target to determine whether the event is being triggered by event bubbling. is.

Use this in your click function like this and see it in action:

  $ ('. Divver'). ('Click', function (e) {if (e.target! == this) return; thefunc ();}); Var thefunc = function myfunc () {warning ('OK'); }   

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -