Reputation: 668
I'm using some jQuery effects on my images. But when i click load more button, don't working JQuery next images. Problem is Dom ready. So, i want to use my jQuery codes with .live but i don't know how to use .live
Please help me, thank you.
1:
var hoverImg = '<div class="hoverimg"></div>';
$(".thumb").each(function(){
$(this).children("div").each(function(){
$(this).find("a").append(hoverImg);
});
});
$(".thumb div").hover(function() {
$(this).find(".hoverimg").animate({ opacity: 'toggle' });
});
$(".thumb").hover(function() {
$(this).find("div").each(function(){
$(this).find(".shadow").fadeOut(500);
});
});
2:
var shadowImg = '<div class="shadow"></div>';
$(".thumb").each(function(){
$(this).children("div").each(function(){
$(this).append(shadowImg);
});
});
3:
var c = '';
var d = '';
$('.view-content div.views-row').each(function(){
c = 0;
d = 0;
var i = 1;
d = $(this).find('.thumbimg').length;
$(this).find('.thumbimg').each(function(){
sayi=i++;
$(this).append('<div class="img_no">0'+sayi+'</div>');
});
});
Upvotes: 0
Views: 89
Reputation: 48817
Use on()
instead.
1.
$(".thumb div").on("hover", function() {
$(this).find(".hoverimg").animate({ opacity: 'toggle' });
});
$(".thumb").on("hover", function() {
$(this).find("div").each(function(){
$(this).find(".shadow").fadeOut(500);
});
});
Upvotes: 0
Reputation: 1103
As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers.
The way it works is like this:
$('#select_something_static').on("click", ".something_dynamic", {'anydata':True}, handler);
You call "on" on a static top level element of DOM (ascendant of dynamic nodes) and then select dynamic nodes. When event triggers on ascendant, jquery searches for selector (".something_dynamic" in my case), and if it was triggered there, calls handler and puts data ({'anydata':True} in my case) in event.data
Upvotes: 1