Javascript Queryselector Attribute Code Example


Example 1: queryselector name attribute


document.querySelectorAll('[property]'); // All with attribute named "property"
document.querySelectorAll('[property="value"]'); // All with "property" set to "value" exactly.

Example 2: queryselector function in javascript


/*The querySelector() method returns the first element that matches a specified 
CSS selector(s) in the document. Note: The querySelector() method only returns
the first element that matches the specified selectors. To return all the
matches, use the querySelectorAll() method instead.*/


// for example

//for class
document.querySelector(".ClassName")

// for id
document.querySelector("#ID")

// etc.

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable