My Script Only Working From Console
Solution 1:
You're most likely running that script before the elements that it references exist.
Make sure that the <script>
tag comes later in the page than the element with the class table
or wrap your entire script in:
$(function(){
... Your entire script
});
in order to ensure that it does not execute until the DOM is ready.
Solution 2:
Try wrapping the whole thing with this:
$(document).ready(function () { /* existing code */ });
The browser may be executing your code before the page has loaded and therefore before the elements exist.
Solution 3:
A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside $( document ).ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute. Code included inside $( window ).load(function() { ... }) will run once the entire page (images or iframes), not just the DOM, is ready.
Try wrapping your code in this
$(document).ready(function() {
// Your code here
});
Post a Comment for "My Script Only Working From Console"