Jquery count specific character in div -
i have php code generates <a>
tags , final output looks like:
<div id='link1'> <a style="font-size:10pt; color: #008056" href="somelink">name</a> <b>;</b> </div>
my question how can count of semicolons in div jquery?
to including in style attribute,try this:
alert($('#link1').html().split(";").length - 1);
and without 1 there in attributes:
alert($('#link1').html().replace(/(<([^>]+)>)/ig,"").split(";").length - 1);
update: find 1 occurence of ;
in , remove it:
$('#link1 a').each(function(){ if($(this).html().split(";").length==2){ $(this).html($(this).html().replace(";","")) }});
Comments
Post a Comment