0

How can i give a line break in the string text? I want to give a line break in this line: "Monday September 21 at 11:00am - September 24 at 12:00pm Pacific Time"

in the below code.

This is what I am doing.

<script>
$(document).ready(function() {
$('div.when ul.details p:contains("Sunday, September 20, 2015 - Thursday, September 24, 2015")').text('Monday September 21 at 11:00am - September 24 at 12:00pm Pacific Time ');
});
</script>
0

1 Answer 1

2

You can use .html() function and put <br> wherever you want line break.

$('div.when ul.details p:contains("Sunday, September 20, 2015 - Thursday, September 24, 2015")')
    .html('Monday<br>September 21 at 11:00am - September 24 at 12:00pm Pacific Time ');

$(function() {
  $('div')
    .html('Monday<br>September 21 at 11:00am - September 24 at 12:00pm Pacific Time ');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div>
</div>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.