using jQuery 1.9.1
The div acts like a container for an image. It has a css styled close icon. When user clicks on the close icon, it removes the image inside the div and also hides the close icon.
These 2 JS functions work fine in chrome & firefox but not in IE8 & IE11. What can be done here.
HTML:
<div>
<a class="closeCompare" rel="237" style="display:block"></a>
<img class="imgCompare" src="pics/1.png" style="display:block"></img>
</div>
JS:
$(document).ready(function(){
RemoveDefaultImage(); //hide the ugly X icon that shows up when there is no image
ShowHideRemoveIcon(); //hide the close icon
})
function RemoveDefaultImage() {
$(".imgCompare").each(function () {
if (($(this).attr('src').length) == 0) {
$(this).css("display", "none");
}
else {
$(this).css("display", "block");
}
})
}
function ShowHideRemoveIcon() {
$(".closeCompare").each(function () {
if ($(this).attr('rel') == 0) {
$(this).css("display", "none");
}
else {
$(this).css("display", "block");
}
})
}
These functions fire on page load and also on a click event