0

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');

3 Answers 3

1

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" />

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

2 Comments

This doesn't appear to be working in Chrome - the second line of the text is cut off. I can only see the upper parts of the 'd' characters on that line
@RoryMcCrossan - Working fine for me in Chrome.
1

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).

Comments

1

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.