-->
UBINADAMU KAZI
  • Home
  • _Contact us
  • _About us
  • New song 2023
  • _New song 2023
  • Videos
  • _Music
  • Form
  • _forms
  • Matangazo
  • _Matangazo
  • _DON BOSCO
  • PDF
  • _HTML PDF
  • _form
Home Document Object Model Document Object Model

Document Object Model

Author - personABY
October 06, 2023
0
share

Document Object Model

  1. Document Object
  2. Properties of document object
  3. Methods of document object
  4. Example of document object

The document object represents the whole html document.

When html document is loaded in the browser, it becomes a document object. It is the root element that represents the html document. It has properties and methods. By the help of document object, we can add dynamic content to our web page.

As mentioned earlier, it is the object of window. So


    

  1. document  

                   Is same as

      

  1. document  

                     According to W3C - "The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."

                          

Properties of document object

Let's see the properties of document object that can be accessed and modified by the document object.


                       


Methods of document object

We can access and change the contents of document by its methods.

The important methods of document object are as follows:

MethodDescription
write("string")writes the given string on the doucment.
writeln("string")writes the given string on the doucment with newline character at the end.
getElementById()returns the element having the given id value.
getElementsByName()returns all the elements having the given name value.
getElementsByTagName()returns all the elements having the given tag name.
getElementsByClassName()returns all the elements having the given class name.


                    

Accessing field value by document object

In this example, we are going to get the value of input text by user. Here, we are using document.form1.name.value to get the value of name field.

Here, document is the root element that represents the html documform1 is the name of the form.

name is the attribute name of the input text.

value is the property, that returns the value of the input text.

Let's see the simple example of document object that prints name with welcome message.

  1. <script type="text/javascript">  
  2. function printvalue(){  
  3. var name=document.form1.name.value;  
  4. alert("Welcome: "+name);  
  5. }  
  6. </script>  
  7.   
  8. <form name="form1">  
  9. Enter Name:<input type="text" name="name"/>  
  10. <input type="button" onclick="printvalue()" value="print name"/>  
  11. </form>  

Output of the above example

Enter Name: 
Tags
Document Object Model
  • Facebook
  • Twitter
  • Whatsapp
  • Newer

  • Older

ABY

ABY

kuanzia sifuri ni kama kuanzia msingi na ni njia bora ya kuanza kitu

    You may like these posts

    Show more

    Post a Comment

    0Comments

    123

    Post a Comment (0)

    Adsense

    HEAD

    UBINADAMU KAZI

    chat on whatssap

    social media

    Start scrolling the page and a strong "Back to top" button will appear in the bottom right corner of the screen.

    Click this button and you will be taken to the top of the page.

    Social Plugin

    • facebook
    • whatsapp
    • instagram
    • youtube
    • Twiter

    Popular Posts

    BENNY SHIZOL-SIPO HURU MP3 Audio
    new song 2023

    BENNY SHIZOL-SIPO HURU MP3 Audio

    ABY ABY August 30, 2023
    Music

    Music

    May 04, 2023
    KIKOSI CHA YA CHA SIKU YA KWANZA
    MICHEZO

    KIKOSI CHA YA CHA SIKU YA KWANZA

    June 03, 2023
    How to add Google Forms to your website
    Google Forms to your website

    How to add Google Forms to your website

    October 11, 2023

    Comments

    4/comments/show

    Labels

    • "3
    • "ADVERTISEMENT2
    • ADVERTISEMENT2
    • BONGO FLEVA10
    • BURUDANI5
    • CHUO CHA UFUNDI MATANGAZO1
    • code za link ya kudownload1
    • DESICN1
    • Document Object Model1
    • EDUCATION1
    • Event5
    • Features and Examples1
    • Film4
    • FORM2
    • forms1
    • Google Forms1
    • Google Forms to your website1
    • HA tunnel free internet and settings1
    • HABARI22
    • HISTORIA4
    • How TO - More Button in Navbar1
    • How TO - Read More Read Less Button1
    • How To Make Signup Page Using HTML And CSS | Create ...1
    • html4
    • ICT1
    • Instrumental1
    • Java script object1
    • JavaScript Classes1
    • JavaScript Form Validation1
    • LISHE2
    • LOGO2
    • MAFUNZO1
    • MICHEZO24
    • MISEMO7
    • MUSIC7
    • NEW SONG2
    • new song 20233
    • PDF4
    • POSTER DESIGN1
    • SIMULIZI3
    • story1
    • TANGAZO4
    • TRAINING1
    • Web Browser – Definition1
    UBINADAMU KAZI
    Powered by Blogger
    https://policies.google.com/privacy?hl=en

    Chat on WhatsApp

    https://wa.me/0629602255

    Report Abuse

    Search This Blog

    POST ARCHIVE

    • 2023146
    • 202410

    Facebook

    UBINADAMU KAZI

    • UBINADAMU KAZI
      -

    Random Posts

    3/random/post-list
    • Home
    • About
    • Contact
    • Home
    • Features
    • _Multi DropDown
    • __DropDown 1
    • __DropDown 2
    • __DropDown 3
    • _ShortCodes
    • _SiteMap
    • _Error Page
    • Mega Menu
    • Documentation
    • _Web Doc
    • _Video Doc

    Footer Menu Widget

    • Home
    • About
    • Contact Us

    Text

    Inatoa matangazo yanafasi za masomo kama vile computer,tailor, cooker, Rehabilitation, education, football and e.t.c

    Contact form

    Name

    Email *

    Message *

    Followers

    Tags

    • "
    • "ADVERTISEMENT
    • ADVERTISEMENT
    • BONGO FLEVA
    • BURUDANI
    • CHUO CHA UFUNDI MATANGAZO
    • code za link ya kudownload
    • DESICN
    • Document Object Model
    • EDUCATION
    • Event
    • Features and Examples
    • Film
    • FORM
    • forms
    • Google Forms
    • Google Forms to your website
    • HA tunnel free internet and settings
    • HABARI
    • HISTORIA
    • How TO - More Button in Navbar
    • How TO - Read More Read Less Button
    • How To Make Signup Page Using HTML And CSS | Create ...
    • html
    • ICT
    • Instrumental
    • Java script object
    • JavaScript Classes
    • JavaScript Form Validation
    • LISHE
    • LOGO
    • MAFUNZO
    • MICHEZO
    • MISEMO
    • MUSIC
    • NEW SONG
    • new song 2023
    • PDF
    • POSTER DESIGN
    • SIMULIZI
    • story
    • TANGAZO
    • TRAINING
    • Web Browser – Definition

    About Us

    About Us
    FACEBOOK ubina damu kazi

    Categories

    • " (3)
    • "ADVERTISEMENT (2)
    • ADVERTISEMENT (2)
    • BONGO FLEVA (10)
    • BURUDANI (5)
    • CHUO CHA UFUNDI MATANGAZO (1)
    • code za link ya kudownload (1)
    • DESICN (1)
    • Document Object Model (1)
    • EDUCATION (1)
    • Event (5)
    • Features and Examples (1)
    • Film (4)
    • FORM (2)
    • forms (1)
    • Google Forms (1)
    • Google Forms to your website (1)
    • HA tunnel free internet and settings (1)
    • HABARI (22)
    • HISTORIA (4)
    • How TO - More Button in Navbar (1)
    • How TO - Read More Read Less Button (1)
    • How To Make Signup Page Using HTML And CSS | Create ... (1)
    • html (4)
    • ICT (1)
    • Instrumental (1)
    • Java script object (1)
    • JavaScript Classes (1)
    • JavaScript Form Validation (1)
    • LISHE (2)
    • LOGO (2)
    • MAFUNZO (1)
    • MICHEZO (24)
    • MISEMO (7)
    • MUSIC (7)
    • NEW SONG (2)
    • new song 2023 (3)
    • PDF (4)
    • POSTER DESIGN (1)
    • SIMULIZI (3)
    • story (1)
    • TANGAZO (4)
    • TRAINING (1)
    • Web Browser – Definition (1)

    Translate

    {ads}

    Responsive Advertisement

    Subscribe Us

    Footer Menu Widget

    • Home
    • About
    • Contact Us

    Random Posts

    3/random/post-list

    Privacy policy

    https://policies.google.com/privacy?hl=en

    Subscribe Us

    Most Popular

    October 20, 2023

    form

    Form

    Form











    UBINADAMU KAZI

    Made with education and dis abled children

    UkTemplate is Designed Theme for Giving Enhanced look Various Features are available Which is designed in User friendly to handle by Piki Developers. Simple and elegant themes for making it more comfortable
    Design by - Free Blogger Templates | Distributed by Free Blogger Templates
    • Home
    • About
    • Contact us
    • Privacy Policy
    • Whatssap

    Contact form

    Share to other apps
  • Facebook
  • Twitter
  • Whatsapp
  • Telegram
  • Pinterest
  • LinkedIn
  • Reddit
  • Tumblr
  • Email
  • Copy Post Link