Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Javascript HTML DOM

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 107
    Comment on it

    In Javascript, we can add, delete or edit any HTML element, attributes, values and their corresponding content. DOM stands for Document Object Model that is used in Javascript to represent complete HTML document displayed in web browser.

    We can get HTML element in Javascript through following ways

    1. document.getElementById()  -  Used to find an element by its id
    2. document.getElementsByTagName() - Used to find elements by tag name
    3. document.getElementsByClassName() - Used to find elements by class name

     

    We can change the HTML elements by using-

    • element.innerHTML= it change the inner HTML of an element

    • element.attribute= change the attribute of an HTML element

    • element.setAttribute(attribute,value) -change the attribute of an HTML element

    examples->

    document.getElementById("abc1").innerHTML="Hello Javascript"; document.getElementById("abc2").src="ABC.jpg";

     

    WE CAN ADD OR DELETE THE html ELEMENTS IN Javascript by using the following ways->

     

    • document.createElement() create an HTML element.

    • document.removeChild()  remove an HTML element.

    • document.appendChild() add an HTML element.

    • document.replaceChild() replace an HTML element.

    • document.write(text) write into the HTML output stream.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: