Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery count specific character in div

Tags:

jquery

I have a php code that generates some <a> tags and the final output looks like:

<div id='link1'>
<a style="font-size:10pt; color: #008056" href="somelink">Name</a>
<b>;</b>
</div>

My question is how can I count all of the semicolons in that div with jquery?

like image 977
user986959 Avatar asked Jan 10 '23 19:01

user986959


1 Answers

I don't know what you are up to, but if you need it, then you can do:

$('#link1').html().match(/;/g).length

/;/g is the regex that will match all ;

like image 136
Amit Joki Avatar answered Jan 19 '23 01:01

Amit Joki