Dynamically adding a script/function block in jquery -


Edit:

Just wondering whether it is possible to add a function (or static script) block Or a variable in the html's body

Something like that,

  $ ('body'). Add (function () {/../})  

or

  $ ('body'). Attachments ('& lt; scripts & gt; & lt; / script & gt;')  

or

  $ ('body'). Fn.myfunc = function {}  

Is it right to use? Expand instead?

An example is that if I use the external interface, my callback should be defined statically in body / html / js, but not in $ (). Ready Function As long as I do not have a different definition around the world and see it in the $ () ready work.

I ignored this requirement, and the place where I wanted to add dynamic callback functions.

  • To create a script tag in your markup

      $ ('& lt; script / & gt;', {type: 'text / javascript', src: 'http: // ...'}). To add (Document.body);    
  • Use jQuery to expand

      $. Fn.yourmethodname = function () {});  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -