日期:2014-05-16  浏览次数:20310 次

jquery代码解释其中的title,jump to等
$('#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');
  });

------解决方案--------------------
大概就是 根据dom的text值 添加title 提示