简体   繁体   English

我如何链接到外部 <div> 用JavaScript?

[英]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.

相关问题 如何将我的onclick事件链接到外部javascript函数? - How do I link my onclick event to an external javascript function? 如何打开页面上带有链接的javascript div选项卡 - How do I open javascript div tabs with a link on the page 如何将外部驱动器,外部js文件链接到允许javascript的wordpress插件中? - how do I link an external drive, external js file into a wordpress plugin that allows javascript? 如何使用Javascript检测外部链接 - How can I detect an external link with Javascript 如何在外部javascript链接的同一类div中添加ID? - How to add an ID in a same class of div in a external javascript link? 如何在加载时打开javascript div但在单击另一个div链接时隐藏它? - How do I make a javascript div open on load but hide when clicking on another div link? 如何使用 .htaccess 或 Javascript 使外部链接首先通过附属链接? - How do I make external links pass through an affiliate link first using .htaccess or Javascript? 如何将外部Javascript文件链接到Play Framework项目中的html文档? - How do I link external Javascript file to a html document in Play Framework project? 我该如何连结 <div> javascript对象(没有框架)? (Actionscript概念到JS world) - How do I link <div> to javascript object (without framework)? (Actionscript concepts to JS world) 如何在新选项卡中打开div链接Javascript onClick =“window.location - How do I make a div link open in a new tab Javascript onClick="window.location
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM