Reputation: 23
I have this line within a jQuery function:
$(".text-input").val("text in first line - text in second line");
The input
belongs to a form which is sent after being submitted.
EDIT: I use the wordpress plugin contact form 7 for it and the input I have the issue with is a radio button. Contact form 7 supports a so-called "html content type" and also when this is activated, the <br>
-tag does not work.
Is it possible to add a line break which shows up in the mail?
I already tried
\n
\r\n


EDIT: ...and also <br>
in combination with the "html content type" of contact form 7...
But none of these work. Has anyone got an idea?
Upvotes: 0
Views: 2168
Reputation: 1
As suggested by @YotamOmer , try substituting textarea
element for input
element
$("textarea").val("a\nb" );
console.log($("textarea").val());
$("<pre>").text($("textarea").val()).appendTo("body");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<textarea></textarea>
Upvotes: 2
Reputation: 11808
Try to use html </br>
in your jQuery code as follows:
$(".text-input").val("text in first line </br> text in second line");
and set email format to HTML as follows
$mail->IsHTML( true ); // Set emails format to HTML in PHP
Hope it helps....!
Upvotes: 1