I found a simple spinner/loader that uses only one div and one css. When I implemented that, i found that it was not stopping. It goes on and on.... so I inserted window load script given below. still it does not stop. What am I doing wrong?
Here is a fiddle http://jsfiddle.net/qzLdjq3c/5/
$(window).load(function() {
$('.spinner').show();
$(".spinner").hide();
});
you don't even use jQuery (on the left side under included libraries) in your example. second you use # instead of a dot (class) selector .... and third, in jsFiddle, look at the left side. You already run the js on the onLoad...you can't just fire it again (i think), anyway, you are wrong at everything imaginably possible. fix what I said and try again.
Related
Been making this websites for a bit today as I've been getting back into making websites. I'm trying to use jquery and have even tried pure javascript to get this click button to work. I went through and copied and pasted the entirety of this pages code into jsfiddle and for some reason it refuses to work in my code but works just fine when I put it into jsfiddle.
So when you click the button on the top right, its going to give the div below a new class. You can see it works here in jsfiddle but for some reason it refuses to work in my copy on my computer.
My html page is correctly loading jquery because I've used .resize() already but it refuses to allow me to use any version of click in any way or form.
Does anyone have any insight as to what may cause this click function to stop working?
// find elements
var banner = $("#banner-message")
var button = $("button")
// handle click and add class
button.on("click", function(){
banner.addClass("alt")
})
https://jsfiddle.net/nathanahartmann/a3s9zjk6/3/
Browser plugins? I know I've shot myself in the foot because my ad blocking or social media blocking plugins mess with frameworks and other java-script behavior.
Seems to work fine now: JS Fiddle
You were missing a lot of ';'s throughout this function:
var banner = $("#banner-message");
var button = $("#rHotBar");
// handle click and add class
button.on('click', function(){
banner.addClass("alt");
});
Similarly, you were referencing the image for var button, not the outer class, the click was registering on the outer div, not the image itself! :)
Weirdest thing ever, It's where it's referencing Jquery in relation to my javascript. For some reason I just posted
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="js/javascript.js"></script>
a second time down below to see what it would do and for some reason it started working. Not really sure why it's doing this but it seemed to work for some reason. It's not referencing Jquery correctly somehow?
For some reason when I try and select an element from the page it only works if I put a timeout of 0 milliseconds. If I don't put the timeout it just returns what is there before the Ionic framework has been loaded. Any ideas? Below is my code.
The order of loading is jQuery, Ionic, Custom Script (as seen below).
Working
ionic.DomUtil.ready(function(){
setTimeout(function(){console.log($('body').html())},0);
});
Not Working
ionic.DomUtil.ready(function(){
console.log($('body').html());
});
EDIT: Obviously I could just put a timeout on everything I want to do but that's bad practice so would be nice to know the underlying cause!
EDIT (2): I have managed to get it do show the HTML doing the following... However, it is not ideal...
$(document).ready(function(){
console.log($(this).find('body')[0]);
});
It's almost as if some jQuery functions are not working even though the $ is being initiated otherwise it return $ is undefined.
I don't know ionic, but you tried with jquery stand alone? like this:
$(document).ready(function(){
console.log($('body'));
});
Maybe there are other way to do the same with ionic
My website is www.codtelevision.com.
If you look at the home page, it is perfect, but when you go to another page, it is big and looks weird. How do I fix it, and what is wrong? Thanks! If you need some code, I will be glad to post some, or you can view it on my site.
I just looked at chrome developer tools, and found this error:
Uncaught ReferenceError: jQuery is not defined
How do I fix this?
You have jQuery included after your jQuery code on your other pages (it needs to be included before). So you end up with just a block of code that isn't functioning as a ticker. Put the call before it and you'll be good.
its because the ticker expands the height as more content gets added and everything is positioned absolute, you need to position something other then absolute, maybe relative , or arrange the elements so they have room to expand
I think you forget add ticker-active class to your other pages. And make sure you call the initialize javascript function.
I have some jQuery that runs on a page. As a short-term fix I want to remove the code within the tags (containing the JS), that are on the page so that this jQuery does NOT run.
Is there any way that I can do this, or stop the code from running? I want to revert back to the typical DOM state, not the manipulated one...
Edit:
I have a script tag on the page that runs some javascript.
Due to certain limitations, I can't simply remove this - I have to include a javascript file to remove this script tag / OR prevent this javascript from running.
I want to revert back to how the page should look without having been manipulated by the script tag that is already on the page.
If you can only include a javascript file, you could try re-declaring the jquery object so it can't run:
jQuery = null;
$ = null;
That would kill jQuery providing it's loaded after. This however would probably cause of lot of javascript errors. On that trail of thought, you could just plug in some broken JS and it would stop jQuery from executing if it's before the jQuery stuff.
I can't think on a scenario where it's needed.
And indeed it's impossible to revert the DOM after manipulation. reset button doesn't revert the DOM
if its in a method you can just use return false; before your code runs, you can also just comment out your code, or wrap your code in a method that never runs:
$("p").hide();
becomes:
function() {
$("p").hide();
}
Or have I misunderstood your question?
Just move your code out of the jQuery(document).ready function, that should make the HTML stay the way it was.
After reading your additions in edit, I think the only to see the page before loading that script would be to add a break-point using Firebug script console at that particular script.
Edit: Add further answer after reading the OPs edit.
the only way I can think of you achieving this without manipulating the source or dom would be to test for a cookie prior to code execution,if it does not exist then set it and continue executing the rest of your code something like this. When you want to revert changes made in the dom back to the 'original' just refresh the window and the existence of the cookie will prevent execution a second time
(function() {
if($.cookie('foo') == null) {
$.cookie('foo', 'bar');
$('#alert').click(function() {
alert('run');
});
}
})();
the only flaw I can see in this is if a user rejects the cookie in which case if it really matters I would alert the user and again break out of execution
Hi i trying to bounce a jpg with jquery but its not going anywhere you can check the code at
http://jsfiddle.net/sethportman/WZumy/6/
Some problems:
$("document").load(function(){
should be
$(document).ready(function() {
and
$(this).effect('bounce',1000 )
should be
$(this).effect('bounce', {}, 1000)
and beyond this, you are not loading the UI/Effects plugins, so your particular page doesn't have a .effect() method available.
You have to include jQuery UI for the effect, and be sure that jQuery has loaded properly:
http://jsfiddle.net/WZumy/11/
http://jsfiddle.net/rlemon/WZumy/12/
As posted, you will want to ensure you have loaded the library correctly (in JSFiddle) and ensure you wait for the DOM to load $(document).ready
dont know if you ever had this answered. but here is a fixed fiddle.
http://jsfiddle.net/WZumy/17/