Examples of using JavaScript to access and manipulate the HTML DOM objects.
Write text to the output with document.write()Write formatted text to the output with document.write()Return the number of anchors in a documentReturn the innerHTML of the first anchor in a documentReturn the number of forms in a documentReturn the name of the first form in a documentReturn the number of images in a documentReturn the id of the first image in a documentReturn the number of links in a documentReturn the id of the first link in a documentReturn all name/value pairs of cookies in a documentReturn the domain name of the server that loaded the documentReturn the date and time the document was last modifiedReturn the URL of the document that loaded the current documentReturn the title of a documentReturn the full URL of a documentOpen an output stream, and add some textOpen an output stream in a new window, and add some textDifference between write() and writeln()Alert innerHTML of an element with a specific IDAlert the number of elements with a specific nameAlert the number of elements with a specific tagname
More Document object examples in our JavaScript reference.
Return and set the value of the charset attribute of a linkReturn the value of the href attribute of a linkReturn and set the value of the hreflang attribute of a linkReturn the name of an anchorReturn the relationship between the current document and the linked documentChange the target attribute of a linkReturn the value of the type attribute of a link
More Anchor object examples in our JavaScript reference.
Return the alternate text for an area in an image-mapReturn the coordinates of an area in an image-mapReturn the anchor part of the href attribute of an areaReturn the hostname:port for an area in an image-mapReturn the hostname for an area in an image-mapReturn the port for an area in an image-mapReturn the href of an area in an image-mapReturn the pathname for an area in an image-mapReturn the protocol for an area in an image-mapReturn the querystring part of the href attribute of an areaReturn the shape of an area in an image-mapReturn the value of the target attribute for an area in an image-map
More Area object examples in our JavaScript reference.
Return the base URL for all relative URLs on a pageReturn the base target for all links on a page
More Base object examples in our JavaScript reference.
Set a button to disabled when clickedReturn the name of a buttonReturn the type of a buttonReturn the text displayed on a buttonReturn the id of the form a button belongs to
More Button object examples in our JavaScript reference.
Return the value of each element in a formReturn the value of the accept-charset attribute in a formReturn the value of the action attribute in a formReturn the value of the enctype attribute in a formReturn the number of elements in a formReturn the method for sending form dataReturn the name of a formReturn the value of the target attribute in a formReset a formSubmit a form
More Form object examples in our JavaScript reference.
align an iframeReturn the value of the frameborder attribute in an iframeRemove frameborder of an iframeChange the height and width of an iframeReturn the value of the longdesc attribute in an iframeReturn the value of the marginheight attribute in an iframeReturn the value of the marginwidth attribute in an iframeReturn the value of the name attribute in an iframeReturn and set the value of the scrolling attribute in an iframeChange The source attribute of an iframe
More Frame/IFrame object examples in our JavaScript reference.
align an imageReturn the alternate text of an imageAdd border to an imageChange the height and width of an imageSet the hspace and vspace properties of an imageReturn the value of the longdesc attribute of an imageCreate a link to a low-resolution version of an imageReturn the name of an imageChange The source of an imageReturn the value of the usemap attribute of a client-side image-map
More Image object examples in our JavaScript reference.
Which mouse button was clicked?What is the keycode of the key pressed?What are the coordinates of the cursor?What are the coordinates of the cursor, relative to the screen?Was the shift key pressed?Which element was clicked?Which event type occurred?
Disable and enable a dropdown listGet the id of the form that contains the dropdown listGet the number of options in the dropdown listTurn the dropdown list into a multiline listSelect multiple options in a dropdown listAlert the selected option in a dropdown listAlert the index of the selected option in a dropdown listChange the text of the selected optionRemove options from a dropdown list
Change the width of a table borderChange the cellPadding and cellSpacing of a tableSpecify frames of a tableSpecify rules for a tableInnerHTML of a rowInnerHTML of a cellCreate a caption for a tableAdd rows to a tableAdd cells to a table rowalign the cell content in a table rowVertical align the cell content in a table rowalign the cell content in a single cellVertical align the cell content in a single cellChange the content of a table cellChange the colspan of a table row
Your Query was successfully sent!