English 中文(简体)
图一 圆顶线中图像质量选择器
原标题:Figure out jQuery selector for an image in a link in a span in a div

我在 trouble忙地为以下这些密码的图像挑选人。 原文为$(g.gallery )[0];将投入使用,但它也尝试了$(g.advance-link )$( gallery ).find(img) [0];

感谢你们的帮助!

JS Fiddle:

传真:

<div class="gallery front">
    <span class="image-wrapper current">
        <a class="advance-link" rel="history" href="#1" title="Title #10">
            <img alt="Title #10" src="../img/10.jpeg">
        </a>
    </span>
</div>
最佳回答

有了这种构造,就有很多机会获得图像:

快速而容易

$( .advance-link>img )

(仅供参考:)

$( div.gallery.front>span.image-wrapper.current>a.advance-link>img )
问题回答
$( .gallery .image-wrapper .advance-link img ).css( border ,  10px solid black );

仅像CSS选择者一样使用。

如同,对事先连接的管治所含每一图像进行检测,必须由图像-图像-图像-图像-校正控制在“彩色”内。

如果你想要获得“金”结果,请考虑:

  • result[0] will give you the DOM node and no jQuery object, so result[0].attr( href ) will be an error
  • result.eq(0) will give you a jQuery Object just containing the first result, so result.eq(0).attr( href ) will work.
$( .gallery img ).addClass( test );

$(>div.gallery img” should work

$( img.gallery ) your image doesnt have the class gallery one of its parents does. $( img.advance-link ) your image doesnt have the class advance-link its parent does.

页: 1

$ ("img:eq(0)”).addClass (“test”);





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.