jquery - how to make part of an output in italic - JavaScript -


there quite few questions on web , on website making italic fonts, non mentions how italic part of string.

in case, there form enter book title, author's name , number sold. after clicking button want author's name , number sold normal book title in italic in text area (output).

coding form:

<label for="txtname">author name</label> <input type="text" id="txtname" size="50" placeholder="eg, darwin" maxlength="50">  <label for="txttitle">book title</label> <input type="text" id="txttitle" size="40" placeholder="eg, origin of species" style="font-style:italic" maxlength="100">  <label for="txtnumber">number sold</label> <input type="text" id="txtnumber" size="4" placeholder="eg, 50000" maxlength="9"> 

when user enters book title, type title looks italic value not stay in italic. after required calculations done @ end want title, author , number shown in order:

btitle = bookform.txttitle.value; bname = bookform.txtname.value; bnumber = bookform.txtnumber.value;  concatbook = btitle+" "+bname+" sold "+bnumber+" copies." 

this concatbook shown in text area via function.

the thing want in italic btitle.

thanks reading question

to add italic style (or wathever want) need wrap text want style in span tags. can't insert html inside textarea. should use <div contenteditable="true"></div> instead.

take @ minimal demo.

html:

<div contenteditable="true"></div> 

css:

span{     font-style: italic; } 

javascript:

var concatbook = "<span>by</span> sold copies." $('div').html(concatbook); 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -