[jQuery] Noob Question - .add() not working in IE?
Hello group,
I try to dynamically add some tags and content to an existing element
(basically a toggle-link, that's only to be seen if JS is active and
that slideToggles a div). Somehow my code doesn't work in IE, although
it works fine in other browsers like Firefox or Safari:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++
JQuery:
$(document).ready(function(){
// hide div on pageready:
if( $("div.reduction-wrap") ){
$("div.reduction-wrap").hide();
// add toggle link with icon to headline
with( $("#toggle-link") ){
children('img').append('<img src="images/pfeil-blau-r.gif"
id="toggle-icon" alt="">');
append(' <span>show</span>');
html( '<a href="javascript:;" id="reduction-toggle">'+$("#toggle-
link").html()+'</a>');
}
// click on link toggles hidden div:
$("#reduction-toggle").click( function() {
$("div.reduction-wrap").slideToggle("normal",
function(){
if( $("div.reduction-wrap").attr("style") == "display: none;") {
$("#reduction-toggle").children("span").html("show");
$("#toggle-icon").attr({src:"images/pfeil-blau-r.gif", id:
"toggle-icon", alt: ""});
} else {
$("#reduction-toggle").children("span").html("hide");
$("#toggle-icon").attr({src:"images/pfeil-blau-u.gif", id:
"toggle-icon", alt: ""});
}
});
// make sure nothing happens with the link:
this.blur();
return false;
});
}
});
HTML:
<h3 id="toggle-link"><img src="images/icon-reductions.gif" alt="" />
Title</h3>
<div class="reduction-wrap">content</div>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++
What is wrong with that? IE will hide the div, but no link-markup is
inserted to the html.
Thanks for any hint or shove in the right direction...
Tom