Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67469

How do I load an external javascript function in an html element?

$
0
0

I have a sample.js file which contains

document.write('This is a sample text');

And I have this script <script src="https://example.com/sample.js"></script> in external website. Where-ever I use this script, sample.js is loaded immediately.

But I want to load the above script in multiple Html <div> or other elements, where we define something like id="example" or class="example" or data-sample-js

So how do I modify the sample.js file to achieve this.


Viewing all articles
Browse latest Browse all 67469

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>