First of all, I have read, after reading it, and after using it, I reached a different problem Yes, he showed me how to insert a script tag, but when it "erases" the entire page:
I want to add a counter timer script using jQuery. Id = "counter" after paragraph and insert "counter" to the same place: so instead of this code:
I will get this code:
& lt; Body & gt; & Lt; P & gt; Start of the site & lt; / P & gt; & Lt; Table id = "timer_table" & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; P id = "counter" style = "color: red;" & Gt; Here's the counter: & lt; / P & gt; & Lt; Script & gt; Var myCountdown1 = new countdown ({time: 316}); & Lt; / Script & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt; & Lt; P & gt; The rest of the site ... & lt; / P & gt; & Lt; / Body & gt; And a new countdown will be displayed where the script was added. I use this firebug console, I am running it: (as it is written, hard, it still does not work well)
var script = Document.createElement ("script"); Script.type = "text / javascript"; Script.src = "js_folder / js1.js"; After $ ('# counter') (script) js1.js is simple:
var myCountdown1 = new countdown ({time: 316}); It does not work well, instead of getting this result: I get this one:
And when I try to see the page source I do not get anything.
To collect it: How to use jquery id = "counter" bunch immediately after paragraph? And it will work as if this line is already written in the original HTML. In addition to this, I do not have access to the html source of the page, if I were I would add it myself and it will work well, as shown in the first picture link. . That's why I'm being forced to use Jquery.
You can use yourself here (to try 2 links):
This is what I want:
But doing it with jquery:
Note, in the second link, try entering
var myCountdown1 = new countdown ({time: 316}); in SS1, and see what happens thanks.
Instead of trying to insert script tags, use the code to insert from the countdown timer Please see this for work example, in the right place.
The main part is to add a container to your HTML (in the example, it has an ID of target_location with div . So HTML gets (after running JS code to insert div)
gt; & lt; p & gt; start of site & lt; / p & Gt; Table id = "timer_table"> gt; & lt; tr & gt; & lt; td & gt; & lt; p id = "counter" style = "color: red;" & gt; here Counter is: & lt; / tr & lt; / t & lt; / t And then JS (which adds a new divan and then runs the countdown)
$ ('# counter'). ('& Lt; Div id = "target_location" & gt; & lt; / div & gt;'); var myCountdown1 = new countdown ( {Time: 316, Goal: 'target_location'});
No comments:
Post a Comment