我不知道为什么我无法链接到其他页面。 logcat
的错误是语法错误。有人可以帮忙吗?谢谢您
for (var i = 0; i < arr.length; i++) {
$("#forumtable").append("<tr><td>" + "<b>Topic: </b>" + arr[i].topic_name + "<b><br>Content: </b>"
+ arr[i].topic_content + "<b><br>Date: </b>" + arr[i].topic_date + "<b><br>By: </b>" + arr[i].topic_creator
+ "<b><br>Total Views: </b>" + arr[i].topic_views + "</td><td><a href='#' class='ui-btn' onClick=window.location='forumdetails.html?topic_id=" + arr[i].topic_id + " &cat_id=" + arr[i].cat_id + "'>View </a></tr><br><br>");
}
最佳答案
您有引号问题,您可以在 onclick
周围添加转义双引号 \"
:
... onClick=\"window.location='forumdetails.html?topic_id="+arr[i].topic_id+" &cat_id="+arr[i].cat_id+"'\">View ...
希望这有帮助。
关于javascript - 我想使用此代码链接到另一个页面,并使用从当前页面获取的 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41825409/