- This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
Viewing 10 posts - 1 through 10 (of 10 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › $(div).ready(function(){ — Is this possible?
Just wondering if this is possible to do?
$(div).ready(function(){
//code
});
Is there a particular reason why you are trying to do that?
Would this not work:
$(document).ready(function(){
$("#your-div").....
});
I can’t seem to get it to work. http://jsfiddle.net/kra3r/
I thought that’s exactly why we have this amazing plugin: https://github.com/desandro/imagesloaded
Using the .ready()
method on the document would suggest all elements within the DOM are ready to be used so using the following is sufficient.
$(function() {
// jQuery code here...
});
The philosophy of the ready() event in jQuery is based on the DomReady event of Vanilla Javascript, that is usually thrown by the window object. For other objects, like images, or divs, use the load() event.
Hi All,
Why won’t the .load event work? But the Hover Does?
This Code Works:
$(document).ready(function() {
$(".TH").hover(function() {
$(this).attr("value", "##IVULP##"*1000);
});
});
This Code Doesn’t Work:
$(document).ready(function() {
$(".TH").load(function() {
$(this).attr("value", "##IVULP##"*1000);
});
});
I agree with “SgtLegend” his suggestion is the best practice.
I agree with “SgtLegend” using the $function method is good coding practice and one should definitely learn to do things the best way from the start.
Is there a reason why you want to add a .ready to a div?
@jcoder – load() isn’t going to do what you want it to.
See my previous post about using the imagesLoaded plugin.
Thanks for all the Great Help Everyone!