Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #34117
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2017-10-16 15:42 -0700 |
| Message-ID | <57cd274f-acb0-4405-b64a-e188d2fa3ae5@googlegroups.com> (permalink) |
| Subject | stopImmediatePropogation |
| From | JRough <janis.rough@gmail.com> |
Currently how these boxes work is if you click the green box you see the child clicked in console. If you click red box you see both parent and child clicked in console. I want to stop propogation so you only see parent clicked or child clicked in console. I have a syntax error on the parentClicked listener. I was tryiing to chain the console.log() method so I could see what is happening but it is giving me a syntax error. tia,
<!DOCTYPE html>
<html>
<body>
<span onclick=parentClicked(event);
style= "position:absolute;left:0; top:0;display:block; width:100px; height:100px; background-color:green; position:0;" id="parent" >
</span>
<span onclick=childClicked();
style = "position:absolute;left:0;top:0;display:block;
width:500px; height:200px; background-color:red;z-index:-1;"
</span>
<script type="text/javascript">
var x = document.getelementById("parent");
function parentClicked(event){
x.addEventListener('click',e.stopImmediatePropogation().console.log("parent Clicked")},false)}
function childClicked(){ console.log("child Clicked");}
</script>
</body>
</html>
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
stopImmediatePropogation JRough <janis.rough@gmail.com> - 2017-10-16 15:42 -0700
Re: stopImmediatePropogation "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-10-19 12:08 -0700
Re: stopImmediatePropogation JRough <janis.rough@gmail.com> - 2017-10-19 17:02 -0700
csiph-web