简体   繁体   中英

convert html tags to string

My ajax call returns a strings where my first string will be code like this

 response[0]=2 

and

 response[1]= Enter the reasons the application is being returned,<br><br><span style="color: red; font-weight: bold;">* Caution! The text of this Message will be included in notices sent to the applicant *</span>

and i am assigning this to the id of my input tag like this

document.getElementById('messageHint').value = response[1] ;

But it doesnt render these <br> and <span> tags in to Html,instead it just shows them in the same format.How do i need to fix this issue.

I tried different apporches like parse.Html() and $html.prop('outerHTML'); but neither one showed me the desired out put.

I think you need to use document.getElementById('messageHint').innerHTML instead.

LIVE DEMO

 You can give only one style to one placeholder like this:

 <style>

 input::-webkit-input-placeholder { font-size: 16pt; color: #555; }
 input::-moz-placeholder { font-size: 16pt; color: #555; }
 input:-ms-input-placeholder { font-size: 16pt; color: #555; }
 input:-moz-placeholder { font-size: 16pt; color: #555; }  

 input.other::-webkit-input-placeholder { font-size: 12pt; color: red; }
 input.other::-moz-placeholder { font-size: 12pt; color: red; }
 input.other:-ms-input-placeholder { font-size: 12pt; color: red; }
 input.other:-moz-placeholder { font-size: 12pt; color: red; }

 </style>

 <input type="text" placeholder="Hello"></input>
 <input type="text" class="other" placeholder="Hello"></input>

 and yes, .innerhtml is used to put the content into a div, not into an input field. so that's not useful to you in anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM