To include style attributes, try the following:
alert($('#link1').html().split(";").length - 1);
And get without one, which is in the attributes:
alert($('#link1').html().replace(/(<([^>]+)>)/ig,"").split(";").length - 1);
Working demo
Update: To find one of the elements ;in and delete it:
$('#link1 a').each(function(){
if($(this).html().split(";").length==2){
$(this).html($(this).html().replace(";",""))
}});
Working demo
source
share