我find(sel)
用来更改所有匹配的元素的css属性sel
:如果元素有一个position
集合,那么它应该得到那个position
,否则它应该得到relative
。
$("#mydiv").find("form").css({ "z-index": 2, "position": jQuery(this).css("position") || "relative", "background-color": "green" })
不工作..最好的方法来做到这一点?
试试这个.css()的变体
$("#mydiv").find("form").css({
"z-index": 2,
"position": function(){
return jQuery(this).css("position") || "relative"
},
"background-color": "green"
})