Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

matches method in javascript

<ul id="birds">
  <li>Orange-winged parrot</li>
  <li id="h" class="endangered">Philippine eagle</li>
  <li>Great white pelican</li>
</ul>

<script type="text/javascript">
  var birds = document.getElementsByTagName('li');

  for (var i = 0; i < birds.length; i++) {
    if (birds[i].matches('#h')) {
      console.log('The ' + birds[i].textContent + ' is endangered!');
    }
  }
</script>
Comment

How To Use Matches() In JavaScript

let abc =			  document.getElementById("abc");
console.log(abc.matches('.myclass'));	  
/*yields true. Asks 'does this element have this selector' */
Comment

PREVIOUS NEXT
Code Example
Javascript :: vuejs list items from axios 
Javascript :: javascript Symbol Methods 
Javascript :: documentelement javascript 
Javascript :: what is axios used for 
Javascript :: v-show example in vue js 
Javascript :: nodejs cache data 
Javascript :: plus in javascript 
Javascript :: list in react native 
Javascript :: schema knex.js 
Javascript :: bootstrap pop modal from another modal 
Javascript :: how to delete an exact element of array 
Javascript :: how to do something once in javascript 
Javascript :: how to print json.stringify of nested objects 
Javascript :: format function shift the date one day up date-fns 
Javascript :: javascript make http request 
Javascript :: create random password javascript 
Javascript :: react functional component example 
Javascript :: how i get selected class of li in jquery 
Javascript :: how to disable option after select using jquery 
Javascript :: send a message in every guild discord.js 
Javascript :: JQuery .hasClass for multiple values in an if statement 
Javascript :: array class javascript 
Javascript :: javascript frames 
Javascript :: remove first character javascript 
Javascript :: take a screenshot javascript of canvas 
Javascript :: Recursion In DOM 
Javascript :: chart js 
Javascript :: sessionstorage in javascript 
Javascript :: read more css js 
Javascript :: angular auth guard 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =