How JavaScript changes HTML Images
This article mainly introduces JavaScript how to change the HTML image, the article is very detailed, has a certain reference value, interested friends must read it!
JavaScript: reaction to events
Example
Click me!
The alert () function is not commonly used in JavaScript, but it is very convenient for code testing.
The onclick event is just one of many events that you will learn in this tutorial.
JavaScript: changing the content of HTML
Using JavaScript to process HTML content is a very powerful feature.
Example
X=document.getElementById ("demo"); / / find the element
X [XSS _ clean] = "HelloJavaScript"; / / change the content
You will often see document.getElementById ("someid"). This method is defined in HTMLDOM.
DOM (DocumentObjectModel) (document object Model) is the official W3C standard for accessing HTML elements.
You will learn about HTMLDOM in several chapters of this tutorial.
JavaScript: changing HTML ima
This example dynamically changes the source of the HTML (src):
Light up the light bulb
Function changeImage ()
{
Element=document.getElementById ('myimage')
If (element.src.match ("bulbon"))
{
Element.src= "/ images/pic_bulboff.gif"
}
Else
{
Element.src= "/ images/pic_bulbon.gif"
}
}