Separate matching strings from title in HTML using CSS or jQuery -


i working on project requires separation of strings titles listed. titles more 500 difficult change it.

the list of doctors

<div class="dr-title"><h2>dr. nicki mallmann crm 22768</h2></div>  <div class="dr-title"><h2>dr. alexandre manoel varela crm 10113</h2></div>  <div class="dr-title"><h2>dr. arnaldo laffitte stier junior crm 9475</h2></div>  <div class="dr-title"><h2>dr. claudinei colatusso crm 19994</h2></div>

all wrapped in html within h2 elements.

are there possibilities can separate texts starting crm followed unique number?

what looks above. want below

.dr-crm {    display: block;    font-size: 12px;    }
<div class="dr-title"><h2>dr. nicki mallmann <span class="dr-crm">crm 22768</span></h2></div>  <div class="dr-title"><h2>dr. alexandre manoel varela <span class="dr-crm">crm 10113</span></h2></div>  <div class="dr-title"><h2>dr. arnaldo laffitte stier junior <span class="dr-crm">crm 9475</span></h2></div>  <div class="dr-title"><h2>dr. claudinei colatusso <span class="dr-crm">crm 19994</span></h2></div>

is possible css or jquery? tried looking css pseudo selectors not possible. might jquery think possible.

css not powerful enough amend content require in case.

instead, can achieve using javascript providing regular expression replace() method finds crm value , following characters, , wraps them in span. try this:

$('h2').html(function(i, h) {    return h.replace(/(crm.*$)/, '<span class="dr-crm">$1</span>');  });
.dr-crm {       display: block;      font-size: 12px;  } 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <div class="dr-title">    <h2>dr. nicki mallmann crm 22768</h2>  </div>  <div class="dr-title">    <h2>dr. alexandre manoel varela crm 10113</h2>  </div>  <div class="dr-title">    <h2>dr. arnaldo laffitte stier junior crm 9475</h2>  </div>  <div class="dr-title">    <h2>dr. claudinei colatusso crm 19994</h2>  </div>


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -