开发者

Jquery doesn't work with .this

As I've said: Jquery doesn't work .this selection, what am I doing wrong? altho it works with other parametres. Here's code of mt mini gallery that's supposed to enlarge selected image and move down non-selected (works on single elements tho)

$(document).ready(function () {
    $("#content img").click(function () {
        $("#blackb").slideDown("slow");
        $("img", this).animate({
            right: "20%"
        });
        $("img", this).animate({
            top: "20%"
        });
        $("img", this).anima开发者_运维百科te({
            width: 802,
            height: 584
        }, "slow");
        $("#content img").not(this).animate({
            top: "80%"
        }, "slow");
    });
});

HTML part:

<div id="content">

    <img id="second" src="model.jpg" alt="model" />
    <img id="third" src="model.jpg" alt="model" />
    <img id="fourth" src="model.jpg" alt="model" />
    <img id="first" src="model.jpg" alt="model" />
    </div>
<div id="blackb"></div>

CSS part:

#content img {
    position: absolute;
    top: 50%;
    right: 50%;
    display: none;
    width: 160px;
    height: 116px;
    border: 2px solid white;
    z-index: 10;
}
#blackb{
    display: none;
    position: absolute;
    top: 0;
    width: 1280px;
    height: 888px;
    background: black;
    opacity: 0.7;
    z-index: 9;
}


$('img', this) is looking for an image node in the context of your image node that was clicked.

Since an image can't be a child of an image, it doesn't make any sense.

You can either select with $(this), or bind the click to something higher up and continue to use this as the context.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜