Response title
This is preview!
I'm using jQuery to created a linked TOC that appears in a dialog box. The function I wrote to do so finds all the h4
's in the page and
id
s to link to li
s title
s and href
s to the anchors so the links point to the original h4
sli
s li
s to a ol
the in dialog div
However, in IE7, the cloned h4
s are not getting turned in li
s. Works in FireFox. In IE7, everything happens as it does in FireFox, just that the the .replaceWith()
is seemingly ignore... why?
Looks like this:
$('#content h4').each(function(index) {
index = index + 1;
$(this)
.attr('id', 'tutorial_' + index)
.before(function() {
return '<div class="how_to">HOW TO<div><span>' + index + '</span></div></div>';
})
.clone()
.replaceWith("<li>" + $(this).text() + "</li>")
.wrapInner("<a></a>")
.find('a')
.click(function(){
$("#dialog").dialog("close");
})
.attr({
'title': 'jump to ' + $(this).text(),
'href': '#tutorial_' + index
})
.end()
.appendTo('#dialog ol')
});
In action at: http://f1shw1ck.com/jquery_sandbox/tutorials.html
Gotten suggestions elsewhere this is a IE7 bug, so happy to chalk it up to that and not an error on my part.
© 2013 jQuery Foundation
Sponsored by and others.