Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

My code is very simple, as I am just learning to use JavaScript.

I am trying to make a HTML5 button element perform a simple alert function when clicked on. However, with the following code, the button does nothing.

     function theFunction(){
            alert("Hi there");
        }
 <button type="button" onlick="theFunction()">Button</button>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
183 views
Welcome To Ask or Share your Answers For Others

1 Answer

It's onclick=func_name not onlick

function theFunction(){
            alert("Hi there");
        }
<button type="button" onclick="theFunction()">Button</button>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...