【发布时间】:2018-04-25 16:27:39
【问题描述】:
我使用 html 创建了一个带有文本的链接,并且我想在用户单击它时创建它转到特定的 url。我是javascript新手!!
这是我的代码
<a class="dt-button add_new_table_entry DTTT_button DTTT_button_new" tabindex="0" aria-controls="table_1" href="#">
<span>Add new</span>
</a>
我的脚本
$("dt-button add_new_table_entry DTTT_button DTTT_button_new").click(function () {
window.location="http://project.co/add-new/";
});
更新 我已经创建了我的脚本
let classic = document.getElementsByClassName('add_new DTTT_button DTTT_button_new');
for (var i=0; i < classic.length; i++) {
classic[i].addEventListener("click", clickfunc, false);
}
function.clickfunc(){
document.location.href="http://google.com";
}
但给出错误意外令牌;
【问题讨论】:
标签: javascript jquery url hyperlink