简体   繁体   中英

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. The div name is totalDiv , and I have it display a calculated amount in the page. It won't let me specify which div I'm wanting, so I was wondering if I should do something like formId.totalDiv.value . Any suggestions?

Thanks!

You can use jQuery. To set a value use $("#totalDiv").html("your text here");

Or

Without jQuery use document.getElementById("totalDiv").innerHTML = "your text here";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM