Reputation: 6834
I want to remove 12:00:00 AM from following string.
<div class="modal-body">
<p>1/11/2016 12:00:00 AM - 1/13/2016 12:00:00 AM</p>
</div>
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");
Upvotes: 1
Views: 3027
Reputation: 240868
You could use the .replace()
method:
$('.modal-body > p').text(function () {
return $(this).text().replace(/12:00:00 AM/g, '');
});
Result:
<div class="modal-body">
<p>1/11/2016 - 1/13/2016</p>
</div>
If you only want to replace the first occurrence, just remove the g
flag.
Upvotes: 7