$('#content h2').each(function(index) { //选择所有id号为content下的h2标签,获取的是content中h2的index?
var chapterTitle = $(this);
var chapterId = 'chapter-' + (index + 1);
chapterTitle.attr('id', chapterId);
$('<a></a>').text(chapterTitle.text())
.attr({
'title': 'Jump to ' + chapterTitle.text(),
'href': '#' + chapterId
})
.appendTo('#page-contents div');
});
var chapterTitle = $(this);
var chapterId = 'chapter-' + (index + 1);
chapterTitle.attr('id', chapterId);
$('<a></a>').text(chapterTitle.text())
.attr({
'title': 'Jump to ' + chapterTitle.text(),
'href': '#' + chapterId
})
.appendTo('#page-contents div');
});
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货