JSFiddle - React, Tailwind, and code Playground

by vasi_32

HTML

<div id="parent">
  <div id=child_1_of_parent>...</div>
  <div id=child_2_of_parent>...</div>
  <div id=child_3_of_parent>...</div>
  <div id=some_other_id_1>...</div>
  <div id=some_other_id_2>...</div>
</div>

JavaScript

(function(){

/* Matching pattern*/
$('#parent').children().each(function(){
   if( $(this).attr('id').match("_of_parent") ) {
        console.log($(this));
   }
});

/*Matching pattern end here*/

/* Using Attribute Selector */
var a =($("div[id ^='child_'][id $='_of_parent']"))
console.log(a)
/* Attribute selector end here*/
}())