HREF正在被修改,超出我的控制范围。。。? 我不确定这是jQuery,JavaScript还是浏览器中的怪癖,但是请考虑这个代码: for(rowIdx=0;rowIdx<theResultSet.rows.length;rowIdx++) { thisLine = $("#TestTemplateLI").clone().attr({'id':'test_'+rowIdx}).appendTo("#test_exerciseListUL"); thisLine.find('[href*="#pageExercise_EXERCISENUMBER"]').each( function(i) {this.href = this.href.replace('EXERCISENUMBER', rowIdx)} ); } for(rowIdx=0;rowIdx)

HREF正在被修改,超出我的控制范围。。。? 我不确定这是jQuery,JavaScript还是浏览器中的怪癖,但是请考虑这个代码: for(rowIdx=0;rowIdx<theResultSet.rows.length;rowIdx++) { thisLine = $("#TestTemplateLI").clone().attr({'id':'test_'+rowIdx}).appendTo("#test_exerciseListUL"); thisLine.find('[href*="#pageExercise_EXERCISENUMBER"]').each( function(i) {this.href = this.href.replace('EXERCISENUMBER', rowIdx)} ); } for(rowIdx=0;rowIdx),javascript,jquery,href,Javascript,Jquery,Href,将返回锚指向的完全限定URL 您可以使用jQuery的attr函数返回所需内容: var $this = $(this); $this.attr("href", $this.attr("href").replace('EXERCISENUMBER', rowIdx)); 这是一篇很好的帖子,解释了.attr(“href”)是如何“规范化”的 将返回锚指向的完全限定URL 您可以使用jQuery的attr函数返回所需内容: var $this = $(this); $this.attr("hre

将返回锚指向的完全限定URL

您可以使用jQuery的
attr
函数返回所需内容:

var $this = $(this);
$this.attr("href", $this.attr("href").replace('EXERCISENUMBER', rowIdx));
这是一篇很好的帖子,解释了
.attr(“href”)
是如何“规范化”的

将返回锚指向的完全限定URL

您可以使用jQuery的
attr
函数返回所需内容:

var $this = $(this);
$this.attr("href", $this.attr("href").replace('EXERCISENUMBER', rowIdx));

这是一篇很好的帖子,解释了
.attr(“href”)
如何“规范化”

绑定一个click函数,然后使用
window.location.hash=$(this.attr('href');
看看它是如何工作的:)你可能必须使用live,因为li是动态的,你也可能需要使用e.preventDefault()绑定一个click函数,然后使用
window.location.hash=$(this.attr('href')看看它是如何工作的:)你可能必须使用live,因为li是动态的,而且你可能还需要使用e.preventDefault()哇。这里的UI需要更多的帮助。哇。这里的UI需要更多的帮助。
var $this = $(this);
$this.attr("href", $this.attr("href").replace('EXERCISENUMBER', rowIdx));