我需要从脚本中删除rel属性平均值,而不是图像id或任何值

I need to remove the rel attribute mean value from script and instead the image id or any value

本文关键字:图像 任何值 id 平均值 属性 脚本 rel 删除      更新时间:2023-09-26

我需要从脚本中删除rel值而不是图像id或任何值我的意思是通过某种方式生成rel属性或删除或通过某种方式避免此属性

HTML

文本在这里关闭X

<article class="col img_prev2">
  <img src="img/slideshow/slideshow2.jpg" alt="#img2" rel="1" class="thumb_main_page">
  <h5>Text Here</h5>
</article>
<article class="col img_prev2">
  <img src="img/slideshow/slideshow3.jpg" alt="#img2" rel="2" class="thumb_main_page">
   <h5>Text Here</h5>
  <div id="img3" class="login-popup">
  </div>
</article>
脚本

var number = $(this).attr('rel');
    number = parseInt(number);
    $('#carousel .slides li:nth-child(' + (number + 1) + ')').click();
    $('#carousel').flexslider({
        animation: "slide",
        controlNav: false,
        animationLoop: false,
        slideshow: false,
        itemWidth: 105,
        itemMargin: 5,
        startAt: number,
        asNavFor: '#slider'
    });

jQuery .removeAttr()

Description:从匹配元素集中的每个元素中删除一个属性。1 <一口>

在你的例子中,最基本的形式是:

$(img).removeAttr('rel');
1

<一口> http://api.jquery.com/removeAttr/