You can put the script into a separate file, then use $.getScript
to load and run it.
Example:
$.getScript("test.js", function(){
alert("Running test.js");
});
More Related Contents:
- Why is my javascript not working
- event.preventDefault() vs. return false
- JavaScript: filter() for Objects
- jQuery click / toggle between two functions
- jQuery.parseJSON throws “Invalid JSON” error due to escaped single quote in JSON
- Force browser to download image files on click
- Event detect when css property changed using Jquery
- Remove querystring from URL
- Playing sound notifications using Javascript?
- Determine if an element has a CSS class with jQuery
- How can I bind to the change event of a textarea in jQuery?
- jQuery Ajax requests are getting cancelled without being sent
- Detect if user is using webview for android/iOS or a regular browser
- Array Like Objects in Javascript
- How to detect right mouse click + paste using JavaScript?
- Popup window to return data to parent on close
- How is a non-breaking space represented in a JavaScript string?
- jQuery index() in vanilla javascript
- What is the difference between JavaScript and jQuery? [closed]
- How to check browser for touchstart support using JS/jQuery?
- How to check if an element is in the view of the user with jquery
- Dynamically adding cases to a switch
- jQuery .on(‘change’, function() {} not triggering for dynamically created inputs
- jQuery get html of container including the container itself
- Get the content (text) of an URL after Javascript has run with PHP
- Take User Back to Where They Scrolled to on previous page when clicking Browser Back Button
- Synchronous XMLHttpRequest on the main thread is deprecated
- jQuery: noConflict
- ASP.NET MVC Partial view ajax post?
- Is there any size limitation for ajax post?