Loading javascript in Span/Div in jquery -


I am trying to load the JavaScript script link in div / span. (The script has some pictures and links) The script should come when I run the page, SPAN happens

I have tried with load (), $. Iscript but unfortunately I was unable to do this. My script should run as a document load without any click or action of any user.

HTML

& lt; Span class = "loader" & gt; & Lt; / Span & gt;

Junkies:

  & lt; Script type = "text / javascript" & gt; $ AJAX ({type: "GET", url: "test.js", data type: "script" success: function (strHTML) {$ (".loder") .HTML (strHTML);}); & Lt; / Script & gt;  

I also tried:

  & lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Title & gt; Home and lt; / Title & gt; & Lt; Script src = "https://code.jquery.com/jquery-1.11.1.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Style & gt; & Lt; / Style & gt; & Lt; Script & gt; $ (Document) .ready (function () {var s = document.createElement ("script"); s.type = "text / javascript"; s.src = "test.js"; // using any selector Do $ (".loader"). Append (s);}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Span class = "loader" & gt; & Lt; / Span & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Any help will prove useful.

This may be the right approach, but I tried the following and my work for it ...

  $ (document) .ready (function () {var s = document.createElement ("script"); S.type = "text / javascript"; s.src = "Http: //scriptlocation/test.js"; // Use any selector $ (".loader"). Attachment (s);});  

Could you please specify the link below, it can be useful


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -