【问题标题】:jquery selector selector for class not working(bootpeg) [duplicate]类的jquery选择器选择器不起作用(bootpeg)[重复]
【发布时间】:2017-06-24 12:35:46
【问题描述】:

我正在使用jquery bootpag 在页面上显示分页

<div class="textgray showing"></div>

我应该如何告诉 jQuery 选择这个 div?我尝试了以下没有但这些尝试都不起作用

$(".textgray .showing").html("some text");

$(".textgray showing").html("some text");

P.S 我是前端初学者,请多多包涵

【问题讨论】:

  • $(".textgray.showing")

标签: jquery jquery-selectors


【解决方案1】:

空格表示第二部分在第一部分内(称为descendant combinator)。删除它:

$(".textgray.showing").html("some text");

【讨论】:

  • 这不应该作为错字关闭吗?
  • 错字?不,真的不是。虽然它可能是重复的。找到它,我会关闭问题。
  • 当我说错字时,我的意思是“错别字偏离主题”“一旦你修复了空间就无法复制”有点接近
【解决方案2】:

您不需要在选择器之间放置额外的空间。选择器中的空格查找后代元素:

$(".textgray.showing").html("some text");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-19
    • 2014-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多