Here we store the TextBox value like this:
- var b=document.getElementById('txt1').value;
Now we will write the events (onmouseover,onmouseout an onclick) on our element1, so when we put our mouse over on the element the background color will be Red, for this we will write the following code:
- element1.onmouseover = function() {
- this.style.backgroundColor = "Red";this.style.width="250";this.style.textAlign="center";
- };
So the output will be:
Now when we hover the mouse over it, it will return to its original color, for this we will write the following code:
- element1.onmouseout = function() {
- this.style.backgroundColor = "White";this.style.width="250";this.style.textAlign="center";
- };
Now we want that, when we click on this element, the item will be shown as the selected item, for this, we will write the following code:
- element1.onclick = function() {
- document.getElementById('p1').innerHTML=b;
- document.getElementById('MYList').style.display='none';
- };
So the output will be: