0

I want to insert the break tag before the Estimated Time of Arrival Can Anybody Help

<span class="avl">Excludes: Northern Territory, QLD Far North, QLD Regional, WA Regional, WA Remote Estimated Time of Arrival: 3-8 Business Days,</span>
Jeevan
  • 756
  • 13
  • 39

2 Answers2

3

You can get the text of that particular span and then add <br> tag next to the occurring string as shown.

$(document).ready(function(){
var string = $(".avl").text();
     var usingBreak = string.replace("Estimated Time of Arrival", "<br/>Estimated Time of Arrival");
   $(".avl").html(usingBreak );
});
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
amitguptageek
  • 537
  • 3
  • 13
  • .html() will do the job... [What is the difference between jQuery: text() and html()?](http://stackoverflow.com/questions/1910794/what-is-the-difference-between-jquery-text-and-html) – tgogos Oct 14 '15 at 07:55
2

Use replace function.

Here's the code for that (say you have the content of the span in a variable called str):

var withBreak = str.replace("Estimated Time of Arrival", "<br/>Estimated Time of Arrival");

If you don't have the text stored in a variable, you could use Document.querySelector and then use .text() to get the content of your span. Than after you changed the value you can just set the Text to your edited string.

nameless
  • 1,483
  • 5
  • 32
  • 78