Reputation: 6834
I want to select 8:30 space
with space that comes from server, I want to select and trim that space and insert it back.
I have tried selecting it like $('.time-wrapper').text()
it give me all text also .prev()
and .next()
with $('.time-wrapper span').prev();
and $('.time-wrapper br').next()
but its not helping also challenge will be insert it back there.
<span class="time-wrapper">8:30 <span> am</span> PT </span>
Any help is appreciated. If I am not clear do ask in comments.
Upvotes: 0
Views: 42
Reputation: 82251
You can use:
var textnode= $('.time-wrapper').contents().first()[0]; //get javascript object of text node
textnode.textContent = textnode.textContent.trim(); //trim and replace text
Upvotes: 1