0

我有以下 HTML:-

<li class="rpItem rpFirst d1">
   <a href="#" class="rpLink 1">
      <span class="rpOut"><img alt="" src="http://localhost:64034/Images/favorites_small.png" class="rpImage">
         <span class="rpExpandHandle"></span>
         <span class="rpText">Product1</span>
      </span>
   </a>
</li>
<li class="rpItem">
    <a href="#" class="rpLink 2">
       <span class="rpOut"><img alt="" src="Images/transparent.png" class="rpImage">
          <span class="rpExpandHandle"></span>
          <span class="rpText">Product2</span>
       </span>
    </a>
</li>
<li class="rpItem">
     <a href="#" class="rpLink 3">
     <span class="rpOut"><img alt="" src="Images/transparent.png" class="rpImage">
        <span class="rpExpandHandle"></span>
        <span class="rpText">Product3</span>
     </span>
     </a>
</li>
<li class="rpItem d1">
     <a href="#" class="rpLink 4">
     <span class="rpOut"><img alt="" src="Images/transparent.png" class="rpImage">
        <span class="rpExpandHandle"></span>
        <span class="rpText">Product4</span>
     </span>
     </a>
</li>
<li class="rpItem d1">
     <a href="#" class="rpLink 5">
     <span class="rpOut"><img alt="" src="Images/transparent.png" class="rpImage">
        <span class="rpExpandHandle"></span>
        <span class="rpText">Product5</span>
     </span>
     </a>
</li>
<li class="rpItem d1">
     <a href="#" class="rpLink 6">
     <span class="rpOut"><img alt="" src="Images/transparent.png" class="rpImage">
        <span class="rpExpandHandle"></span>
        <span class="rpText">Product6</span>
     </span>
     </a>
</li>

我希望针对第一个 li,它具有src="http://localhost:64034/Images/favorites_small.png".

所以我想做类似的事情

if (imagename = favorites_small.png) 然后从该项中移除点击事件,即不允许点击。

我怎样才能做到这一点?

4

3 回答 3

2
$('li img[src*=small.png]').each(function(){
    $(this).parents('a').contents().unwrap();
});

是一个工作的jsFiddle

来源

CSS 选择器
jQuery API - .unwrap()
jQuery API - .parents()

于 2013-04-15T10:18:23.537 回答
1

这可以用 jQuery 在一行中完成:$('li img[src~=imagename]').unbind('click');

于 2013-04-15T10:18:11.650 回答
0

用这个。

var imagesrc = $('selector img').attr('src');

var imagesrc1 = imagesrc.split("/") ;

var isize = imagesrc1.length;

var imagename = imagesrc1[isize-1];

这样,您将获得图像名称,然后进行比较。

如果(图像名=收藏夹_small.png)

于 2013-04-15T10:57:08.377 回答