Search Results

Search found 2 results on 1 pages for 'stazh'.

Page 1/1 | 1 

  • Problem with dynamically added script element - attribute src is empty

    - by Stazh
    Hi there, I have a problem with dynamically added script element (using jQuery). Code for adding new script element to DOM is this: var pScript = document.createElement("script"); pScript.type = "text/javascript"; pScript.src = sFile; // Add element to the end of head element $("head").append(pScript); The script is added with no problem, and the code runs perfectly. But, the problem occurs when I try to find the newly added script. I use this code to iterate through all script elements: var bAdd = true; $("script").each(function() { if(this.src == sFile) bAdd = false; }); (I need this code to prevent adding script that is already loaded) Problem is that all other script elements have src attribute set, but the newly added (dynamically) has not... Any idea?

    Read the article

1