Skip to main content
edited tags; edited title
Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

Trying to club multiple elements in one line using Using jQuery replacestring replacements to make labels bold

Source Link
John
  • 195
  • 6

Trying to club multiple elements in one line using jQuery replace

Instead of having multiple statements like the following, Is it possible to club them into one liner in jQuery?

       var replaced = $("#myContents").html().replace(/Employee:/g,'<b>Employee:</b>');
       $("#myContents").html(replaced);

       var replaced = $("#myContents").html().replace(/SSN:/g,'<b>SSN:</b>');
       $("#myContents").html(replaced);

       var replaced = $("#myContents").html().replace(/DOB:/g,'<b>DOB:</b>');
       $("#myContents").html(replaced);


       var replaced = $("#myContents").html().replace(/Start Date\/Time:/g,'<b>Start Date\/Time:</b>');
       $("#myContents").html(replaced);

       var replaced = $("#myContents").html().replace(/End Date\/Time:/g,'<b>End Date\/Time:</b>');
       $("#myContents").html(replaced);