<div class="content">
<div class="div1" style="background: #afe986">aaaaa</div>
<div class="div2" style="background: #e979c0">bbbbb</div>
</div>
<div class="content">
<div class="div3" style="background: #a5dbe9">ccccc</div>
<div class="div4" style="background: #e9e514">ddddd</div>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
$('.content').hover(function () {
var myhtml = $(this).children();
myhtml[1].hide();
});
</script>
Console过myhtml的内容了,输出没问题的。
难道this访问子节点后调用方法不能这样?
求解,谢谢
与this什么的无关,因为myhtml[1]是原生js的写法,没有办法使用jQuery的方法,你改成myhtml.eq(1).hide()就没问题了。