• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in JavaScript by
Q:
Give a list of the various ways using which an HTML element can be accessed within a JavaScript code?

1 Answer

0 votes
by

A few of HTML element used with JavaScript with ways are:

  1. getElementById(‘idname’): Using this method, you can get an element by the ID name of the element.
  2. getElementsByClass(‘classname’): Using this method, you can get all elements which have a given classname.
  3. getElementsByTagName(‘tagname’): Using this method, you can get all elements which have a given tag name.
  4. querySelector(): The querySelector() function takes the css style selector and returns the first selected element.

Related questions

0 votes
asked Mar 24 in JavaScript by sharadyadav1986
+1 vote
asked Jan 15, 2020 in Angular by rahuljain1
...