Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

tagname js

const btns = document.getElementsByTagName('button');
const btnFirst = btns.item(0);
// to get an item for the HTML collection use indexing, like arrays start
// at index 0
const btnNamed = btns.namedItem('named-btn');
// to get a named item you can use both id & name attributes

btnFirst.onclick = () => {
    console.log('The first item in the collection');
}
btnNamed.onclick = () => {
    console.log('A named item in the collection');
}
Comment

tag name javascript

var heading = document.getElementsByTagName("h1");
// this gets all the h1 tag from html document
// you can let any tag from html and store in a desired variable for manipulation
Comment

PREVIOUS NEXT
Code Example
Javascript :: stripe npm 
Javascript :: locate and delete an object in an array 
Javascript :: js do after delay 
Javascript :: find missing number array javascript 
Javascript :: console.log color 
Javascript :: split a string every n characters javascript 
Javascript :: jest mongoose multiple connections 
Javascript :: textalign javascript 
Javascript :: javascript play sound on click 
Javascript :: how to change the query parameter of the url in javascript 
Javascript :: check if mobile view javascript 
Javascript :: loop through json object javascript 
Javascript :: rn push notification No task registered for key ReactNativeFirebaseMessagingHeadlessTask 
Javascript :: how to set text for label in jquery 
Javascript :: usehistory example 
Javascript :: javascript wait 10 seconds 
Javascript :: mongodb pull multiple 
Javascript :: jquery all elements whose id contains 
Javascript :: nods js fs append to file 
Javascript :: get value of element html js 
Javascript :: datetimepicker set value 
Javascript :: fetch api post req 
Javascript :: call a function whenever routerlink is clicke angular 
Javascript :: Math prime js 
Javascript :: find quotient in javascript 
Javascript :: getting data from firestore using async await 
Javascript :: placeholder in angular 9 select with working required 
Javascript :: vue.js cdn 
Javascript :: codeigniter 3 return json response 
Javascript :: kill node process 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =