1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > html超链接点不了_Html使文本可点击而不会超链接

html超链接点不了_Html使文本可点击而不会超链接

时间:2021-03-23 20:41:23

相关推荐

html超链接点不了_Html使文本可点击而不会超链接

I'm very new to using html and javascript. I want to add the ability to have the option to click on certain text and have the correct javascript execute. Are there any reference code I can look at, or a tutorial that can help me?

解决方案

for semantics I'd use a tag like this:

Clicky

to make the button look like normal text you can use css:

button.link { background:none;border:none; }

and for easiness of handing click I'd use jquery like so:

$(".link").click(function(){

//your JS here

});

but if you have an ID on the button you can use plain JS like this:

var button = document.getElementById("your-button-id");

button.onclick = function(){

//do stuff

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。