Reputation: 3628
I'm new to the whole jquery game but I found a great tut snippet that is just what I need, but I need the latter half to happen as the page loads, not when the button is clicked.
$(window).load(function(){
$('iframe').load(function() {
$('iframe').show()
$('#loading').hide();
});
$('#button').click(function() {
$('#loading').show();
$('iframe').attr( "src", "http://www.apple.com/");
});
});
So the action that would happen following a button click actually happens right as the page is loaded... no waiting for the button to be clicked. It's a simple thing, just don't know how to do it and really do not need to learn the in and outs of jQuery as this is the only time I need to use it.
Upvotes: 0
Views: 2397
Reputation: 692
Pretty sure you want $('#button').onclick(...) not $('#button').click(...)
The click function simulates and fires a click event.
Upvotes: 0
Reputation: 9111
Have you tried this ?
$(window).load(function(){
$('iframe').load(function() {
$('iframe').show()
$('iframe').attr( "src", "http://www.apple.com/");
});
Upvotes: 0
Reputation: 69905
Try this
$(window).load(function(){
$('iframe').load(function() {
$('iframe').show()
$('#loading').hide();
});
$('#loading').show();
$('iframe').attr( "src", "http://www.apple.com/");
});
Upvotes: 0
Reputation: 22016
$(window).load(function(){
$('iframe').load(function() {
$('iframe').show()
$('#loading').hide();
});
$('#loading').show();
$('iframe').attr( "src", "http://www.apple.com/");
});
Upvotes: 2