Jquery填充输入或textarea [英] Jquery to populate input or textarea
本文介绍了Jquery填充输入或textarea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<div id="example"></div>
<script type="text/javascript">
jah = "<p>Browser CodeName: " + navigator.appCodeName + "</p>";
jah+= "<p>Browser Name: " + navigator.appName + "</p>";
jah+= "<p>Browser Version: " + navigator.appVersion + "</p>";
jah+= "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>";
jah+= "<p>Platform: " + navigator.platform + "</p>";
jah+= "<p>User-agent header: " + navigator.userAgent + "</p>";
document.getElementById("example").innerHTML=jah;
</script>
我正在使用上面的代码来编译我需要从表单中收集的一些浏览器信息。如何将该信息传递给Input或Textarea?
I'm using the above code to compile some browser info I need to collect from a form. How can I get that info passed to a Input or Textarea?
提前致谢!
推荐答案
如果你想使用纯净的JavaScript代替jQuery,试试这个:
If you want to use pure JavaScript instead of jQuery, try this:
<form><textarea id="ta"></textarea></form>
<script type="text/javascript">
jah = "whatever you want";
var ta = document.getElementById('ta');
ta.value = jah;
</script>
分配 .value
等于jQuery函数 .val(v);
Assigning .value
equals jQuery function .val(v);
这篇关于Jquery填充输入或textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文