jQuery div未选择

时间:2019-03-14 05:51:13

标签: javascript jquery html

我要选择一个div

<section class="grid">
 <div class="results clearfix">
 ....
 </div>
</section>

当我尝试以下代码时

 var sortGridList = $(".grid > .results");

效果很好

类似地,我还有另一节

var sortMapList = $(".map > .results");

console.log(sortMapList.text());
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section class="map">
   <div class="col-sm-4 results">
   Sample Text
   </div>
</section>

它不起作用

上面的代码有什么问题吗?

任何帮助或建议将不胜感激

预先感谢

1 个答案:

答案 0 :(得分:1)

没有任何原因导致其无法正常工作。看一下 Connecting to remote task manager + 'xxxxxxxxxxxxx' has failed. This might indicate that the remote task manager has been lost". 中的错误(如果有更多需要澄清的地方)。

console
var sortGridList = $(".grid > .results");
sortGridList.css("background-color", "yellow");

var sortMapList = $(".map > .results") ;
sortMapList.css("background-color", "red");