<a class="btn2" onclick="alertbox()">link </a>
<script>
function alertbox() {
alert("alert box");
}
</script>
I have tried to use the css below to try and fix it but that does not make it clickable it only changes the cursor
.btn2 {
cursor: pointer;
}
but that only changes the cursor when i hover over it and dont make it actually clickable
sorry if really obvious answer only recently i started to do html
答案 0 :(得分:1)
向<a>
添加一些文字并且有效:
.btn2 {
cursor: pointer;
}
&#13;
<a class="btn2" onclick=alertbox();>Link</a>
<script>
function alertbox() {
alert("alert box")}
</script>
&#13;
答案 1 :(得分:0)
你错过了&gt;在锚标签中 和你的功能结束时的一个}
<a class="btn2" onclick=alertbox()>button </a>
<script> function alertbox() {
alert("alert box");
}
</script>