InterviewSolution
| 1. |
Should I always put my JavaScript in the head tag of my HTML file? |
|
Answer» Use CSS and jQuery to replace the DEFAULT JavaScript alert pop up. Let us first see how to create an alert in JavaScript and how the default looks: <!DOCTYPE html> <html> <body> <h1>Alerts in JavaScript</h1> <button onclick="show()">Display</button> <script> function show() { alert("This is an alert box!"); } </script> </body> </html>The output displays a button, which is to be clicked to generate an alert: On clicking the above button, the following alert generates:
Under <style> above, we added the CSS code. The output displays a button which is to be clicked to generate an alert: On clicking the above “Display” button, the following alert is visible which we styled. The background color is not blue. The button color and style is also changed: |
|