Skip to content
Advertisement

How to dynamically change the script src by taking user value from user input?

I’m trying to dynamically change the <script src=oldValue”/> InputValue depends on what user types in input and after submitting page will reload with new <script src=newValue”/>

JavaScript

Advertisement

Answer

The first example changes the src attribute for the script element. The second example is inserting a new script element. I don’t know what would work best in your case.

The first example:

JavaScript
JavaScript

The second example:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement