Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 超链接:设置onClick_Javascript_Html_Twitter Bootstrap 3 - Fatal编程技术网

Javascript 超链接:设置onClick

Javascript 超链接:设置onClick,javascript,html,twitter-bootstrap-3,Javascript,Html,Twitter Bootstrap 3,你好 我有一个超链接 Click in this ¿ <a href="#" id="hr" class="alert-link"><strong>Link</strong> ?</a> 点击这里 我想使用一个OnClick使用Javascript函数的函数。我怎么做 我试着做类似的事情,但没有成功 Click in this ¿ <a href="#" OnClick="myfuncti()"id="hr" class="alert-

你好

我有一个超链接

 Click in this ¿ <a href="#" id="hr" class="alert-link"><strong>Link</strong> ?</a>
点击这里
我想使用一个OnClick使用Javascript函数的函数。我怎么做

我试着做类似的事情,但没有成功

Click in this ¿ <a href="#" OnClick="myfuncti()"id="hr" class="alert-link"><strong>Link</strong> ?</a>
点击这里

谢谢。

如果需要函数,请在单击时添加以下属性:

<a href="#" onclick="function()" id="hr" class="alert-link"><strong>Link</strong> ?</a>

还要确保JS和HTML文件链接正确,函数名与调用的函数名匹配。

试试下面的代码

函数myfunction(){
//做你想做的。。。
}

锚定标记本身有一个操作,因此回调函数应该有一个默认方法才能工作

例如

<a href="#" onclick="foo()" id="hr" class="alert-link"><strong>Link</strong> ?</a>

function foo() {
 event.preventDefault();
}


那么您想在单击链接时打开警报?只需使用
onclick=“alert(“message”)”
我想在单击超链接后调用一个函数,该选项属于boostrap,并且已经显示您的问题不完整。不确定您想要完成什么。谢谢,但我担心代码不起作用,href似乎比onclick事件更重要……因此,当我单击超链接时,它不会触发该功能。可能会将超链接设置为一个空白字符串,如
href=“”
?谢谢,但我担心代码不起作用,似乎href比onclick事件更重要……因此,当我单击超链接时,它不会触发该函数。