【发布时间】:2013-03-31 11:05:24
【问题描述】:
我在 html 中使用文本区域标签,我必须在单独的行中打印成分,但即使使用回车键,当我将文本区域的值传递给变量并打印它时,它也会出现在一行中。
以下是我的代码 sn-p :
<div data-role="fieldcontain">
<label for="name">Ingredients</label>
<textarea rows="4" cols="50" id="new_ingredients">
</textarea>
</div>
$( '#new_recipe' ).live( 'pagebeforeshow',function(event){
var temp1 = $("#new_ingredients").val();
$("#testing").text(temp1);
});
<div data-role="page" id="new_recipe">
<div class="content" id="testing" ></div>
</div>
请帮助我了解当用户按下回车键时如何获取不同行中的数据。提前谢谢。
【问题讨论】:
-
仅供参考,live() 已弃用当前版本api.jquery.com/live
标签: javascript jquery html