JAVA SCRIPT 1
JAVA SCRIPT 1
Events are actions or occurrences, like a user clicking a button, moving the
mouse, or typing in a field, that JavaScript can detect and respond to.
They make web pages interactive and dynamic, enhancing user experience.
a. onchange Event
Definition: Triggers when the value of an input element (e.g., text field,
dropdown) changes and the user moves focus away.
code:
<p id="output"></p>
<script>
function updateName() {
</script>
Explanation:
<input> Tag:Creates a text box where the user can type their name.
b. onmouseover Event
Use Case: Highlighting or changing styles when the user hovers over an
element.
<button onmouseover="highlight(this)"
onmouseout="removeHighlight(this)">Hover over me</button>
<script>
function highlight(element) {
element.style.backgroundColor = "yellow";
function removeHighlight(element) {
element.style.backgroundColor = "";
</script>
Explanation:
<button> Tag:
JavaScript Functions:
highlight(element):
c. onmouseout Event