Reputation: 190
I want to change the value of my submit input. but It is not just a plain text. for example the value should be like this
Submit query
Send code
but the problem is when I put a br tag between texts, my html code will print exactly. It is possible to change value with query but with printing every texts even html code with that ...
$('input[type=submit]').val('submit<br />send code');
Upvotes: 0
Views: 72
Reputation: 337560
You cannot put HTML code in to the value of an input button. However, you can set HTML in a button
with type="submit"
applied:
$('button').click(function() {
$(this).html('submit<br />send code');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>Original value</button>
Upvotes: 1
Reputation: 207861
Use \n
instead as your break
$('input[type=submit]').val('submit\nsend code');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="submit" />
Upvotes: 1
Reputation: 943143
No.
Form controls hold only plain text.
You can put markup in a submit button by using a <button>
element instead of an <input>
element (then you need to use use .html()
instead of .val()
to change it with JavaScript).
Upvotes: 1