jQuery: How to find an image by its src

前端 未结 4 914
遇见更好的自我
遇见更好的自我 2020-12-07 22:08

I need to find an img by name and src. I have been trying the following to no avail.

var s = $(\"img[src=\'/images/greendot.gif\'][name=\'BS\']\");
         


        
4条回答
  •  旧时难觅i
    2020-12-07 22:43

    without seeing the html I would say check your path.

    $("img[src$='greendot.gif'][name='BS']")
    

    given the following HTML:

    
    

    this jquery worked:

    var x = $("img[src$='twitter_logo_header.png'][name='logo']");
    alert(x.attr("src"));
    

提交回复
热议问题