我有一个页面使用jQuery来构建基于现有HTML元素的链接和锚定标记。它适用于除IE之外的所有浏览器,其中锚标签的输出有点不同。动态生成的链接无法在IE中工作
其他浏览器:
<a class="courseshortcut" name="TitleJanuary12-13,2013"></a>
Internet Explorer中:
<a name="TitleJanuary12-13,2013" class="courseshortcut"/>
生成的链接,这些锚标签是这样的:
<a href="#TitleJanuary12-13,2013">January 12-13, 2013 - Miami, FL</a>
代码的文档中的以下部分.ready函数添加锚点:
//adds the anchor tags
$('.courseentry').each(function() {
var str = $(this).find('.coursetitle').html() + $(this).find('.coursedate').html();
$(this).prepend("<a class='courseshortcut' name='" + str.replace(/\s+/g, '') + "'></a>");
});
我不明白为什么会发生这个问题。有人能够启发我吗?测试脚本的更完整版本可以在here找到。
这有什么错呢? – SLaks 2013-02-11 22:59:25
@ SLaks-无效HTML以外的其他内容? – RobG 2013-02-11 23:04:56
对不起,我应该更具体。 这些链接在IE中不起作用。在我的测试页面上,它们可以与Safari,Chrome,Firefox一起使用。 – Drew02 2013-02-11 23:06:07