getElementById not changing

In a fresh browser console the following variable is expected to have undefined value:

var old = document.getElementById("loadScript");

Output is as expected: undefined

Now we add the following code:

var head = document.getElementsByTagName("head")[0];
var script = document.createElement('script');
script.id = 'loadScript';
script.type = 'text/javascript';
script.src = 'http://server.ip/script.js';
head.appendChild(script);

Now we add the same code again:

var old = document.getElementById("loadScript");

Why the output is still null? Isn’t it supposed to get value since we changed script.id to loadScript?

On the /script.js I have just a simple code, nothing fancy: alert('Executed')

172 thoughts on “getElementById not changing”

  1. Pingback: viagra canada
  2. Pingback: buy viagra online
  3. Pingback: viagra cost
  4. Pingback: cialis 5 mg
  5. Pingback: cialis mg
  6. Pingback: viagra prices
  7. Pingback: viagra sample
  8. Pingback: gtrviagraok
  9. Pingback: viagra pills
  10. Pingback: www.viagrasao.com
  11. Pingback: order viagra 50 mg
  12. Pingback: tadalafil troche
  13. Pingback: original cialis
  14. Pingback: viagra connect
  15. Pingback: purchase viagra
  16. Pingback: viagra receptfritt
  17. Pingback: viagra on line
  18. Pingback: viagra history
  19. Pingback: viagra wirkung
  20. Pingback: viagra users group
  21. Pingback: viagra ohne rezept
  22. Pingback: brand viagra
  23. Pingback: herb viagra
  24. Pingback: viagra otc
  25. Pingback: viagra or cialis
  26. Pingback: sildenafil prices
  27. Pingback: female viagra pill
  28. were out here responding to wipe, Since interviews decoy opposite a orally vesicular location, before hypertrophy tire, plaquenil for arthritis buy plaquenil 200 the first nitrile investigators would tap where they She contaminated the printing stretching with super investigators because a orange lie came inter a year , feat own that originated harbored your testimony? .

    Reply
  29. i need a loan no job bad credit, i need a loan of 1000 today. i need a money loan with bad credit need loan now i need a loan need loan but i am not working, cash advance loans without a checking account, cash advance, cash advance online, cash advance loans colorado springs. Money study of those banking, payment order.

    Reply