Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140161

Javascript buttons and alerts not functioning properly. Alerts appear when page is refreshed but my buttons are not appearing

$
0
0

I am currently working on the beginning stages of js and trying to create buttons and alerts with it. when i write my code, the alerts work but my buttons are not appearing. when i inspect my webpage, the buttons dont even appear in the code. any suggestions on what i can do to fix this?

'''javascript
<!--alertmessage.html-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>alert message</title>
</head>

<body>
    <p>Javascript.</p>
    <script type="text/javascript" src="js/code.js">
    </script>
</body>
</html>

<!--code.js-->
 window.alert("Welcome to Javascript");

<!--buttons.html-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>alert message</title>
</head>

<body>
    <p>Javascript.</p>
    <button onclick="alert('How can I help you?')">Click me.</button>
    <button id="button 2">Click me.</button>
    <script>
        document.getElementbyId("button 2").onclick=function(){
            alert("You have just clicked me!");
        }
    </script>
</body>
</html>
'''

Viewing all articles
Browse latest Browse all 140161

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>