Doing some text swapping (testimonials fade in/out) with JavaScript and want to insert the equivalent of a <br/>
inside the quotes so the author of the quote is on the next line. In the below code, I tried following the instructions at JavaScript: How to add line breaks to an HTML textarea?, but am not sure how to insert /\n\r?/g
to make it work.
<script type="text/javascript">
var text = document.forms[0].txt.value;
text = text.replace(/\n\r?/g, '<br />');
</script>
<script type="text/javascript">
window.testimonials = [
'"This was a great experience" /\n\r?/g - Max Cameron, ThinkTank',
'"This was a great experience" /\n\r?/g - Max Cameron, ThinkTank',
"source code"
];
</script>
Is there any way to force it onto the next line? Thanks!
`) or, are those testimonials coming from a source you cannot edit? – Robot Woods May 22 '12 at 00:26