当我使用query:
为某些元素添加事件处理程序时$('div').mouseover(function () {
});
Iinside函数我有一个元素,我们为其添加事件函数($(this))。 我如何在下面查看此功能:
答案 0 :(得分:1)
您可以将其放入mouseover
事件代码中
$(this).children('div').each( function() { // $(this) is your parent <div>
if ($(this).height() > 300) { // $(this) is the current child <div>
// Do things here...
}
});
答案 1 :(得分:0)
当你进入函数时,this
指的是DIV元素。然后,您可以执行任何您希望了解的内容。
因此,要获得子DIV,您可以使用var childDivs = $('div',this);
。
答案 2 :(得分:0)
$('div').mouseover(function () {
var children = $(this).children("div"); //for immediate child div
if(children.length > 0){
alert("'div' child present");
for(i=0; i < children.length; i++){
if(children[i].height() > 300)
alert("'div' with height more than 300 present");
}
});
更新:
也可以使用children[i].css('height')
。