Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

querySelectorAll multiple lists

var list = document.querySelectorAll("form, p, legend");
Comment

queryselectorall select multiple input types

<html>

<body>

<input type='button' value='F3' class="c2" id="btn_1">
<input type='button' value='F3' class="c3" id="btn_2">
<input type='button' value='F1' class="c2" id="btn_3">

<input type='submit' value='F2' class="c1" id="btn_4">
<input type='submit' value='F1' class="c3" id="btn_5">
<input type='submit' value='F2' class="c1" id="btn_6">

<br/>
<br/>

<button onclick="myFunction()">Try it</button>

<script>
    function myFunction() 
    {
        var arrFiltered = document.querySelectorAll('input');

            arrFiltered.forEach(function (el)
            {                
                var node = document.createElement("p");
                
                node.innerHTML = el.getAttribute('id');

                window.document.body.appendChild(node);
            });
        }
    </script>

</body>

</html>
Comment

queryselectorall of multiple tags

Yes, because querySelectorAll accepts full CSS selectors,
and CSS has the concept of selector groups, which lets you specify 
more than one unrelated selector. For instance:

var list = document.querySelectorAll("form, p, legend");

...will return a list containing any element that is a form or p or legend.

CSS also has the other concept: Restricting based on more criteria. 
You just combine multiple aspects of a selector. For instance:

var list = document.querySelectorAll("div.foo");

...will return a list of all div elements that also (and) 
have the class foo, ignoring other div elements.

You can, of course, combine them:

var list = document.querySelectorAll("div.foo, p.bar, div legend");

...which means "Include any div element that also has the foo class,
any p element that also has the bar class, and any legend element 
thats also inside a div."
Comment

PREVIOUS NEXT
Code Example
Javascript :: confirming the end javascript 
Javascript :: Good Example: Focus moved to AJAX content with tabindex="-1" after a delay 
Javascript :: kendo grid set page number 
Javascript :: array operations = map, filter, find, reduce, some, every, indexOf 
Javascript :: number of substring in a string 
Javascript :: como hacer un contador de tiempo en javascript 
Javascript :: Declaring A Method Outside The Constructor 
Javascript :: react-native navigation homeStack 
Javascript :: An Array Of Functions With Parameter 
Javascript :: es6 javascript return types 
Javascript :: prisma usersWithZeroPosts 
Javascript :: errors thrown inside asynchronous functions will act like uncaught errors 
Javascript :: js beutify node.js 
Javascript :: winston transport file another directory 
Javascript :: use spread operator in max method javascript 
Javascript :: Backbone With Express 
Javascript :: convert milliseconds to seconds javascript 
Javascript :: chart cdn js 
Javascript :: how to get event from iframe 
Javascript :: responsive navbar react 
Javascript :: javascript invert binary tree 
Javascript :: router.push 
Javascript :: math.ceil node js 
Javascript :: nextjs link 
Javascript :: = meaning in javascript 
Javascript :: js pick last element of array 
Javascript :: how dynamique pseudo element in react 
Javascript :: javascript Adding Element to the Outer Array 
Javascript :: javascript Error handling is easier to manage 
Javascript :: react linkify 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =