如何在 html 中显示选定的文本区域值

How to display selected textarea value in html

我在简单的 html 表单上有文本区域。我想显示该文本区域的选定值,就像下拉列表中的选定值一样。我搜索了 google,发现 textarea 没有值属性。那么是否有任何选项可以在 html 中显示选定的文本区域值?

我想在编辑表单时显示它的值,就像编辑时在下拉列表中选择的值一样..

你必须尝试这个编码..

$('#formId :textarea').click(function() {
   alert(this.tagName != 'TEXTAREA' ? this.tagName : this.type);
});

希望这篇link对您有所帮助

http://plnkr.co/edit/ocl4Zcmv4qjXSIxE7IyF?p=preview

jQuery 不需要。使用普通 Java 脚本,您可以实现此功能。

HTML :

<textarea id='123' onkeyup='getvalue()'>
  TEXTAREA
</textarea>

JS :

function getvalue(){

 var a = document.getElementById('123').value;

 alert(a)

}

我是这样写的..它正在工作..

<textarea name="yojana" id="yojana"cols="50" rows="3"><?php echo $delivery_memo_info->yojana;?></textarea>