javascript - Using jQuery with google.load -
I am trying to understand how the Google cdn's google.load method is used when Use the.
Putting the init code in the setOnLoad callback function works great but it does not work to define the function for event handlers in markup. In the example below, the P button works as expected but the Div button does nothing.
Yes, in this example, I can also insert the onclick handler of the devise in setOut callback function, but does it mean that all should be jQuery code?
Help? Thanks
& lt; P id = "p" & gt; Content & lt; / P & gt; & Lt; Button type = "button" id = "btn1" & gt; P & lt; / Button & gt; & Lt; Div id = "div" & gt; Div & lt; / Div & gt; & Lt; Button type = "button" id = "btn2" onclick = "btn2 ()" & gt; Div & lt; / Button & gt; & Lt; Script src = "http://www.google.com/jsapi" & gt; & Lt; / Script & gt; & Lt; Script & gt; Function BTN2 () {$ ("# DIV"). Toggle ("slow"); } Google.load ("jquery", "1.3.2"); Google.setOnLoadCallback (function () {$ ("# btn1"). Click (function () {$ ("p") toggle ("slow");});}); & Lt; / Script & gt; Call your Google jsapi script and google.load
& lt; Head & gt; After running on top of
, it will only output & lt; Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type = "text / javascript" & gt; & Lt; / Script & gt;
Where google.load
was there.
Then insert all your jQuery code inside:
$ (function () {// all your jQuery codes are here}); Which is the short story for $ .ready (function () {});
Comments
Post a Comment