.each function, does not work properly
3 posters
Page 1 of 1
.each function, does not work properly
I try to add a dynamic css (max-height) for each element.
But i find one max-height for all the elements. any ideas?
But i find one max-height for all the elements. any ideas?
- Code:
$(document).ready(function(){
$('.cbreplay').each(function() {
var height = $('.cbrepl-left').height();
var maxheight = height - 28;
$('.cbnota-container').css({'max-height':maxheight});
});
});
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: .each function, does not work properly
Hello Ahmed.K,
You must use the this keyword to refer to the iterated element.
Ex :
I'm assuming .cbrepl-left is a child of .cbreplay, so use $(this).find()
You must use the this keyword to refer to the iterated element.
Ex :
I'm assuming .cbrepl-left is a child of .cbreplay, so use $(this).find()
- Code:
var height = $(this).find('.cbrepl-left').height();
Re: .each function, does not work properly
Try code new
- Code:
$(document).ready(function(){
$('.cbreplay').each(function(a, b) {
var height = $('.cbrepl-left', b).height();
var maxheight = height - 28;
$('.cbnota-container', b).css({'max-height':maxheight});
});
});
Re: .each function, does not work properly
Ah, thanks, It works fine now.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Similar topics
» URL link does not work properly
» Search doesn't work properly
» [ONLY TOPIC]Chat box - refresh, Auto logout, Cant log in Problems
» chat doesn't work properly
» 4 in 1 not working properly
» Search doesn't work properly
» [ONLY TOPIC]Chat box - refresh, Auto logout, Cant log in Problems
» chat doesn't work properly
» 4 in 1 not working properly
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum