jquery - 获取父级的父级?

发布于 2024-08-14 03:39:42 字数 1325 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦旅人picnic 2024-08-21 03:39:42

您的问题不太清楚,但如果您只想“获取父级的父级”,请使用 prev()parents() 选择器。

Your question is not quite clear, but if you just wanted to "get parent of parent", use the prev() or parents() selectors.

幻梦 2024-08-21 03:39:42

只是尝试

destObj: $(".ffts>a")

simply try

destObj: $(".ffts>a")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文