在我的html网站中,我可以通过锚点调用任何javascript函数,如下所示
<a href="javascript:function();"></a>但当我尝试在wordpress菜单选项中添加此选项,然后保存菜单后,所有内容都从那里消失,字段变为空。如何通过wordpress菜单调用函数。
有谁能帮忙吗?
发布于 2014-04-26 00:59:48
如果不看你的JS,很难说问题出在哪里,但你可以试试这个:
<ul>
<li><a id="red" href="#" onclick="myFunction()">List Item with Function</a></li>
<li><a href="#">List Item without Function</a></li>
</ul>
function myFunction(){
document.getElementById('red').setAttribute('style', 'color: red');
}这里有一个小把戏:http://jsfiddle.net/BSshG/1/
或者用JavaScript来处理点击,不用担心改变超文本标记语言:
document.getElementById('red').onclick = function(){
this.style.color = "red";
}另一个难题:http://jsfiddle.net/BSshG/2/
https://stackoverflow.com/questions/23298718
复制相似问题