Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery-can';t选择正确的div_Jquery - Fatal编程技术网

jQuery-can';t选择正确的div

jQuery-can';t选择正确的div,jquery,Jquery,这是一个很常见的问题,但我想不出来。让我先发布我的代码: <div class="myDeskContentRate"> <span class='myDeskContentStar'><img src='star.png'></span> <div class='myDeskContentRateCount'><span class='starCount'>1</span></div>

这是一个很常见的问题,但我想不出来。让我先发布我的代码:

<div class="myDeskContentRate">
    <span class='myDeskContentStar'><img src='star.png'></span>
    <div class='myDeskContentRateCount'><span class='starCount'>1</span></div>
</div>
当一颗星星被点击时,它必须先发布,然后加载,因为它必须更新星星的数量

我的问题是,我无法在divclass='myDeskContentRateCount'中选择span class='starCount'

我可以得到class='myDeskContentRateCount',但这不是我想要的。有没有办法让我获得span class='starCount'

提前谢谢

$('div.myDeskContentRate > div.myDeskContentRateCount > span.starCount');
我会选择它。其他可能性

$('div.myDeskContentRateCount').child('span.starCount');
$('div.myDeskContentRateCount').find('span.starCount');
我会选择它。其他可能性

$('div.myDeskContentRateCount').child('span.starCount');
$('div.myDeskContentRateCount').find('span.starCount');

这将有望解决您的问题:

$starCount = $this.next('.myDeskContentRateCount').find('.starCount');

这将有望解决您的问题:

$starCount = $this.next('.myDeskContentRateCount').find('.starCount');

这也很好地解决了:)既然你是第一个,你就会得到答案:)该死,我明白了。我没注意到这一切都在改变。因此@loannis将得到正确的答案。他的建议很管用。这也很管用:)既然你是第一个,你就会得到答案:)该死,我明白了。我没注意到这一切都在改变。因此@loannis将得到正确的答案。他的建议行得通。