Why does this work and not this (wrapInner() inside a function works but not standalone)
// This entire post is related to IE9 only. All other browsers work
// this works
- if ($('.bttnnew').length) {
$('.bttnnew').addClass('hasIcon').each(function(){
var content = $(this).html();
$(this).html('<span class=txtDesc>'+content+'</span><span class=iconHolder></span>');
});
};
yields:
- <a href="..." class="bttnnew hasIcon"><span class="txtDesc">Default Button Text</span><span class="iconHolder"></span></a>
// But this does NOT work
// in IE 9
- if ($('.bttnnew').length) {
$('.bttnnew').addClass('hasIcon').wrapInner('<span class=txtDesc />').append('<span class=iconHolder />');
};
The second function yields only:
- <a href="..." class="bttnnew hasIcon">Default Button Text</a>
Thoughts?