Dom manipulation of web JavaScript

Source: Internet
Author: User

Today, I first studied the content of the previous review, and then learned that when the mouse pointer to a button, the corresponding background image switch.

<div id= "D1" >
</div>
<input type= "button" value= "1" onmouseover= "dj1 ()" id= "J1" class= "C1" style= "Background-color: #6F3"/>
<input type= "button" value= "2" onmouseover= "Dj2 ()" id= "J2" class= "C1"/>
<input type= "button" value= "3" onmouseover= "Dj3 ()" id= "J3" class= "C1"/>

  

<script>
var A=document.getelementbyid ("J1");
var B=document.getelementbyid ("J2");
var C=document.getelementbyid ("J3");
function dj1 ()
{
var Aa=document.getelementbyid ("D1");
Aa.style.backgroundimage= "url (6upckhin3k5o0006.jpg)";
A.style.backgroundcolor= "#6F3";
B.style.backgroundcolor= "#CCC";
C.style.backgroundcolor= "#CCC";
}
function Dj2 ()
{
var Aa=document.getelementbyid ("D1");
Aa.style.backgroundimage= "url (22.jpg)";
A.style.backgroundcolor= "#CCC";
B.style.backgroundcolor= "#6F3";
C.style.backgroundcolor= "#CCC";
}
function Dj3 ()
{
var Aa=document.getelementbyid ("D1");
Aa.style.backgroundimage= "url (002-1.jpg)";
A.style.backgroundcolor= "#CCC";
B.style.backgroundcolor= "#CCC";
C.style.backgroundcolor= "#6F3";
}
</script>

Later, I learned how to manipulate content, styles, and properties using Window.document.

alert (a.innerhtml); The HTML code and text in the tag are captured.

A.setattribute ("attribute name", "attribute value"); Set a property, add or change all can;

A.getattribute ("attribute name"); Gets the value of the property;

A.removeattribute ("attribute name"); remove an attribute;

Dom manipulation of web JavaScript

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.