我遇到这种情况:jsfiddle.net/T8NZc /
我想要make,当点击div颜色变化div =行高(父)和div = desc时。我怎么能做到这一点?
答案 0 :(得分:1)
$('div.colour').click(function(){
var parent = $(this).parent();
parent...//do something
parent.find('.desc')...//do something
});
答案 1 :(得分:0)
var parentHgt = $('.row').height() + $('.data').height() + $('.desc').height();
// or take out the height value in CSS and use the parent's outer height
// var parentHgt = $('.row').outerHeight();
$('.colour').click(function () {
$(this).css({
'background': '#ccc',
'height': parentHgt + 'px',
});
$(this).text($('.desc').html());
});
<强> Here's the demo 强>