Reputation: 11835
demo
http://jsfiddle.net/bRqAR/2/
this code did not work on the internet explorer (check console).
How can i fix this?
html
<div id="myDiv_1451" class="allDivs">
Hello
<div class="iconDiv"><img src="http://jsfiddle.net/img/keys.png" /></div>
<div style="clear:both;"></div>
</div>
JS
$(document).ready(function() {
$('.allDivs').click(function(e)
{
var divId = this.id.replace(/myDiv_/gi,'');
if(e.target.classList[0] == 'iconDiv' || e.target.parentElement.className == 'iconDiv')
{
alert('click on green iconDiv or on icon');
}
else
{
alert('click on main');
}
});
});
Thanks in advance!
Upvotes: 0
Views: 1284
Reputation: 8881
IE gives this error : Unable to get value of the property '0': object is null or undefined , so change e.target.classList[0]
to e.target.classList == 'iconDiv'
Upvotes: 1
Reputation: 232
I've tried on IE,
delete the [0]
e.target.classList[0] > replace with
e.target.classList == 'iconDiv'
works on chrome and IE
Upvotes: 1