【问题标题】:fadeln script not working wellfadeln 脚本无法正常工作
【发布时间】:2015-04-04 03:31:37
【问题描述】:

我的脚本有问题。我所做的是获取任何标签<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++;
}

我使用 laravel 框架。

图片:

http://prntscr.com/60ystp - 这个类别运行良好

http://prntscr.com/60ysna - 此类别无效

【问题讨论】:

  • 请显示您实际渲染的输出 (HTML)。这个问题与 PHP 或您的服务器端代码无关。
  • 你是什么意思?之后是将代码打印到 html 吗?
  • @idan003 在浏览器中呈现的代码
  • 谁能帮我解决这个问题?

标签: javascript php jquery html laravel


【解决方案1】:

您正在尝试循环一个字符。这个 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>')
}); 

【讨论】:

  • 不好,在我完成循环后,我需要执行

    并关闭它。代码再次运行良好,但在 1 类中不起作用,而在 2 类中起作用。所以我不知道为什么。

  • no 仍在 1 类工作中,在第 2 类中不工作。
猜你喜欢
  • 2014-12-07
  • 1970-01-01
  • 2017-04-08
  • 1970-01-01
  • 2015-07-27
  • 2011-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多