1

How do I change the src of a script with a click?

 <script id="video_load" type="text/javascript" src="something.js"></script>

  <span id="link1">Install</span>

  <script>
      $(document).ready(function () {
          $('#link1').click(function () {    
              $('#video_load').attr('src','somethingelse.js');      
          });
      });
  </script>
dcodesmith
  • 9,285
  • 4
  • 37
  • 38
SamotnyPocitac
  • 299
  • 4
  • 15

1 Answers1

0

I think you really want to use the jQuery GetScript method.

check out this previously asked question. JQuery to load Javascript file dynamically

If you then have a good JavaScript structure in your previous file you could just get the object and clear it something like. Assuming it is a global object.

Something = {};
Community
  • 1
  • 1
Thomas Harris
  • 434
  • 3
  • 14