[英]How do I link to an external <div> with Javascript?
I have an external script which I'm linking to, and it calculates a <div>
element in my HTML
page. 我有一个链接到的外部脚本,它在
HTML
页面中计算一个<div>
元素。 The div name is totalDiv
, and I have it display a calculated amount in the page. div的名称是
totalDiv
,我在页面中显示了计算的金额。 It won't let me specify which div
I'm wanting, so I was wondering if I should do something like formId.totalDiv.value
. 它不会让我指定我想要的
div
,因此我想知道是否应该执行诸如formId.totalDiv.value
类的formId.totalDiv.value
。 Any suggestions? 有什么建议么?
Thanks! 谢谢!
You can use jQuery. 您可以使用jQuery。 To set a value use
$("#totalDiv").html("your text here");
要设置值,请使用
$("#totalDiv").html("your text here");
Or 要么
Without jQuery use document.getElementById("totalDiv").innerHTML = "your text here";
如果没有jQuery,请使用
document.getElementById("totalDiv").innerHTML = "your text here";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.