javascript - div onclick with Form and other elements -


i want fix problem have attaching onclick element div ( , it! )

please @ following code :

<script> function  gotoo(url,idd){ alert(idd); if (idd=="onlyme") window.location=url; } </script> <div id="onlyme" onclick="javascript:gotoo('http://www.google.com', this.id)" style="<-index:-150"> <form><input type="text" name="coap"></form>  <h3>this element click should work!</h3>  <div id="notme"> <h3>in point should not work!</h3> </div>  </div> 

i want onlick triggered in div clicking.

please check example live @ http://modacalcio.com/htmlproblemform.html

the click triggered everywhere, expecially in form input.

obiovusly wish use without deleting onclick in children nodes, have own onclick still need work

also jquery have same problem help?

$('#onlyme').on('click', function(evt) {     if ($(evt.target).parents('#notme').length === 0 && evt.target.id !== 'notme') {         location.href = "http://...";     }        }); 

example fiddle: http://jsfiddle.net/zhkr2/2/

the idea check if event triggered on #notme element or inside element contained in #notme, check if ancestor element


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -