[英]How to show the output in textarea when using $('div') and CSS (JavaScript)
When I use this codes, it Prints the result in a new html page, how can I print the results in a nominated textarea? 当我使用此代码时,它将结果打印在新的html页面中,如何在指定的textarea中打印结果? lets I want the result to be shown in: bookForm.myText.value
让我希望结果显示在:bookForm.myText.value
Update: PLEASE NOTE ONLY THE bTitle IS SUPPOSED TO BE ITALIC 更新:请仅注意bTitle应该是斜体
HTML: HTML:
<div contenteditable="true"></div>
CSS: CSS:
span{
font-style: italic;
}
JavaScript: 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);
Add Textarea in with id "mytext" 在ID为“ mytext”的地方添加Textarea
<textarea id="mytext" name="somename"></textarea>
Add Javascript 添加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');
Step 1 第1步
Create a textarea with id, here id is "myTextarea" 创建一个具有ID的textarea,此处的id为“ myTextarea”
<textarea id="myTextarea" name="somename"></textarea>
Step 2 第2步
Javascript 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.