首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用.jpg选择图像

如何使用.jpg选择图像
EN

Stack Overflow用户
提问于 2010-12-20 01:19:35
回答 3查看 2K关注 0票数 0

有没有什么方法可以让我用.jpg定位图像?

例如,下面的代码放大所有图像。但是,我只想放大.jpg。

代码语言:javascript
复制
/*
 * If a page url contains /art-8 (not cart-8), then do this.
 * Add a link to zoom an image on the first image on a product page  
 */
if (/[^c]art-8/.test(location.pathname)) {

$("#system #product_cont img").wrapAll("<ul class=\"cont_thumb\">").wrap("<li>");
$(".cont_thumb").after("<div style='clear:both;padding-bottom: 20px;'></div> ");



$("ul.cont_thumb li").hover(function(){
    $(this).css({
        'z-index': '10'
    });
    $(this).find('img').addClass("hover").stop().animate({
        marginTop: '0px',
        marginLeft: '-35px',
        top: '50%',
        left: '50%',
        width: '344px',
        height: '258px',
        padding: '0px'
    }, 200);

}, function(){
    $(this).css({
        'z-index': '0'
    });
    $(this).find('img').removeClass("hover").stop().animate({
        marginTop: '0',
        marginLeft: '0',
        top: '0',
        left: '0',
        width: '80px',
        height: '60px',
        padding: '3px'
    }, 400);
});
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2010-12-20 01:23:42

使用$=

代码语言:javascript
复制
$('img[src$=".jpg"]')

http://api.jquery.com/attribute-ends-with-selector/

票数 6
EN

Stack Overflow用户

发布于 2010-12-20 01:24:24

您可以使用选择器img[href$=.jpg], img[href$=.jpeg]

票数 0
EN

Stack Overflow用户

发布于 2010-12-20 01:25:31

替换

代码语言:javascript
复制
$("ul.cont_thumb li").hover(function(){

使用

代码语言:javascript
复制
$("ul.cont_thumb li").filter("img[src$='.jpg']").hover(function(){
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4484130

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档