jQuery selector regular expressions

You can use the filter function to apply more complicated regex matching. Here’s an example which would just match the first three divs: $(‘div’) .filter(function() { return this.id.match(/abc+d/); }) .html(“Matched!”); <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js”></script> <div id=”abcd”>Not matched</div> <div id=”abccd”>Not matched</div> <div id=”abcccd”>Not matched</div> <div id=”abd”>Not matched</div>

Selecting and manipulating CSS pseudo-elements such as ::before and ::after using javascript (or jQuery)

You could also pass the content to the pseudo element with a data attribute and then use jQuery to manipulate that: In HTML: <span>foo</span> In jQuery: $(‘span’).hover(function(){ $(this).attr(‘data-content’,’bar’); }); In CSS: span:after { content: attr(data-content) ‘ any other text you may want’; } If you want to prevent the ‘other text’ from showing up, you … Read more