How remove a specific string from an element’s text using jQuery?

I want to remove 12:00:00 AM from following string.

<div class="modal-body">

1/11/2016 12:00:00 AM - 1/13/2016 12:00:00 AM


The results should be:

1/11/2016 - 1/13/2016

How can I remove just the 12:00:00 AM from complete string all occurrences of it.

$('.modal-body > p').text().remove("12:00:00 AM");


You could use the .replace() method:

Example Here

$('.modal-body > p').text(function () {
  return $(this).text().replace(/12:00:00 AM/g, '');


<div class="modal-body">
  <p>1/11/2016 - 1/13/2016</p>

If you only want to replace the first occurrence, just remove the g flag.