jquery - 获取父级的父级?
我正在使用 jquery.cjobjectScaler 插件(链接文本 )并且由于我无法控制的情况,img 在 div 内超链接......我不有什么方法可以“删除”该标签,我也无法对其重新排序...
所以,原始功能是这样的:
$("#productGrid li img").cjObjectScaler({
destObj: $("#productGrid li img").parent("li"), // must be a jQuery object (required)
method: "fit", // can either be fit or fill (default fill)
fade: 800 // if a positive integer, will hide and fadeIn object n duration (default 0)
});
/* CSS for above */
ul#productGrid li {
position: relative;
display: block;
width: 190px;
height: 150px;
border: 1px solid #ccc;
float: left;
margin-right:
10px; margin-bottom:
10px; overflow: hidden;
}
这是我正在尝试使用的版本...
$(".ffts a img").cjObjectScaler({
destObj: $(".ffts a img").parent("a"),
method: "fill",
});
/* css for above */
.ffts a {
width: 550px;
height: 300px;
}
/* here's the markup */
<div class="ffts">
<a href="/img" style="position: relative;">
<img src="/source/image.jpg" />
</a>
</div>
而且,它确实调整了它的大小,但不是为 ffts 设置的尺寸...我已经验证该样式没有被覆盖,所以不确定从这里去哪里...?
I'm using the jquery.cjobjectScaler plugin (link text ) and due to circumstances beyond my control, the img is hyperlinked within the div... I don't have any way to "strip out" that tag, nor can I reorder it at all...
So, the original function is this:
$("#productGrid li img").cjObjectScaler({
destObj: $("#productGrid li img").parent("li"), // must be a jQuery object (required)
method: "fit", // can either be fit or fill (default fill)
fade: 800 // if a positive integer, will hide and fadeIn object n duration (default 0)
});
/* CSS for above */
ul#productGrid li {
position: relative;
display: block;
width: 190px;
height: 150px;
border: 1px solid #ccc;
float: left;
margin-right:
10px; margin-bottom:
10px; overflow: hidden;
}
And this is the version I'm trying to use...
$(".ffts a img").cjObjectScaler({
destObj: $(".ffts a img").parent("a"),
method: "fill",
});
/* css for above */
.ffts a {
width: 550px;
height: 300px;
}
/* here's the markup */
<div class="ffts">
<a href="/img" style="position: relative;">
<img src="/source/image.jpg" />
</a>
</div>
And, it does resize it, but not to the dimensions set for ffts a... I've verified that that style isn't being overridden, so not sure where to go from here... ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题不太清楚,但如果您只想“获取父级的父级”,请使用
prev()
或parents()
选择器。Your question is not quite clear, but if you just wanted to "get parent of parent", use the
prev()
orparents()
selectors.只是尝试
simply try