i have a question about JavaScript addEventListener, i have two div and in this divs there is a input text.
(please with JavaScript)
i want to register a click only for div not for the input.
<div id="deneme">
<input style="margin: 10px;" type="textbox" />
<div id="new"></div>
</div>
JavaScript:
var divTag = document.getElementsByTagName("div");
for (var i = 0; i < divTag.length; i++) {
if (divTag[i].tagName == "DIV" || divTag[i].tagName == "div") {
if (divTag[i].addEventListener) {
divTag[i].addEventListener('click', redirect,false);
}
else if (divTag[i].attachEvent) {
divTag[i].attachEvent('on' + 'click',redirect);
}
}
}
function redirect(e) {
alert("redirect");
e.stopPropagation();
}
CSS :
#deneme {
width:200px;
height:200px;
background-color:yellow;
}
#new{
width:20px;
height:20px;
background-color:green;
}
can you help me?
Thanks in advance.