fadeln脚本工作不正常

fadeln script not working well

本文关键字:不正常 工作 脚本 fadeln      更新时间:2023-09-26

我的脚本有问题。我所做的是获取任何标记<p>的css id,并在脚本中告诉他:在x之后删除标记<a>。它在Y类中运行良好,但在X类中不起作用,我没有收到任何错误。

我的代码:

jQuery(function ($) {
  var i = '';
  for (i = '9'; i <= '22'; i++) {
    $('div > p.lessonsrow-' + i).find('a[href]').attr('href', '#lock');
    $('div > p.lessonsrow-' + i).find('i.cercale2').replaceWith('<i class="cercale2 fa fa-lock fa-1x"></i>')
  }
});

标签HTML:

foreach ($lessonsid as $row) {
  $html .= $counter % 2 == 0 ? '
    <div class="span12 bar_lessons">
      <p class="lessonsrow-' . $row->id . '">
        <i class="cercale2 glyphicon glyphicon-play fa-1x"></i>
        <a href="' . url() . '/gui/' . $url . '/' . Request::segment(3) . '/lessons/' . $row->courses_id . '/vod/' . $row->id . '">' . trans('lessons.' . $row->name) . '</a>
      </p>
      <p class="text">Lorem ipsum dolor sit amet, con</p>
    </div>' : '
    <div class="span12 bar_lessons2">
      <p class="lessonsrow-' . $row->id . '">
        <i class="cercale2 glyphicon glyphicon-play fa-1x"></i>
        <a href="' . url() . '/gui/' . $url . '/' . Request::segment(3) . '/lessons/' . $row->courses_id . '/vod/' . $row->id . '">' . trans('lessons.' . $row->name) . '</a>
      </p>
      <p class="text">Lorem ipsum dolor sit amet, con</p>
    </div>';
  $counter++;
}

我使用拉拉威尔框架。

图片:

http://prntscr.com/60ystp-这一分类运行良好

http://prntscr.com/60ysna-此类别不起作用

您正在尝试循环一个字符。此for循环将运行0次。试试这个javascript。您的循环还希望在9-22之间进行迭代。我想ID不仅在9-22之间。因此,对所有适用的div>p执行此操作

jQuery(function ($)
{
    $('div.span12 > p').find('a[href]').attr('href', '#lock');
    $('div.span12 > p').find('i.cercale2').replaceWith('<i class="cercale2 fa fa-lock fa-1x"></i>')
});