[英]how to set textarea background transparent to show its contents on div placed behind/above it using either javascript or css only
[英]How to show the output in textarea when using $('div') and CSS (JavaScript)
當我使用此代碼時,它將結果打印在新的html頁面中,如何在指定的textarea中打印結果? 讓我希望結果顯示在:bookForm.myText.value
更新:請僅注意bTitle應該是斜體
HTML:
<div contenteditable="true"></div>
CSS:
span{
font-style: italic;
}
JavaScript:
bTitle = bookForm.txtTitle.value;
bName = bookForm.txtName.value;
bNumber = bookForm.txtNumber.value;
var concatBook = "<span>"+bTitle+"</span> by "+bName+" sold "+bNumber+" Copies."
$('div').html(concatBook);
在ID為“ mytext”的地方添加Textarea
<textarea id="mytext" name="somename"></textarea>
添加JavaScript
bTitle = bookForm.txtTitle.value;
bName = bookForm.txtName.value;
bNumber = bookForm.txtNumber.value;
var concatBook = ""+bTitle+" by "+bName+" sold "+bNumber+" Copies.";
$('#mytext').val(concatBook); //this will display result in textarea
$('#mytext').css('font-style', 'italic');
第1步
創建一個具有ID的textarea,此處的id為“ myTextarea”
<textarea id="myTextarea" name="somename"></textarea>
第2步
Java腳本
bTitle = bookForm.txtTitle.value; bName = bookForm.txtName.value; bNumber = bookForm.txtNumber.value; var concatBook = ""+bTitle+" by "+bName+" sold "+bNumber+" Copies."; $('#myTextarea').val(concatBook); //this will display result in textarea
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.