in my html
website I can call any javascript
function through anchor like this
<a href="javascript:function();"></a>
but when I try to add this in wordpress
menu option then after saving menu , everything vanished from there and field becomes empty. how can I call functions through wordpress
Menu's.
any one can help please ?
It's hard to say what the problem is without seeing your JS, but you could try this:
<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');
}
Here's a fiddle: http://jsfiddle.net/BSshG/1/
Or handle the click even with JavaScript and don't worry about changing the HTML:
document.getElementById('red').onclick = function(){
this.style.color = "red";
}
Another fiddle: http://jsfiddle.net/BSshG/2/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.