[英]Updating div with jQuery not showing on DOM
Some html that is always on the page. 页面上始终有一些HTML。
<div class="info">
<div class="bar"></div>
<div class="rehints">10 REHINTS</div>
<div class="hinter">
<div class="picture monophoto">
<div class="text">BO</div>
<div class="img" style="background-image: url();" onclick=""></div>
</div>
<div class="content">
<div class="one">Hinted by:</div>
<div class="two"><a href=""></a></div>
</div>
</div>
<div class="partnertext">Partnered Hint</div>
<div style="clear:both;"></div>
</div>
</div>
I have added the following jquery to hide it in the case there is are no 'hit 我添加了以下jQuery以在没有“命中”的情况下将其隐藏
var selectedProductsInfo = viewHint.querySelector('.rehints').textContent;
var selectedProductsHints = a.clones + ((a.clones == 1)? " REHINT" : " REHINTS");
if(pathsArray[1] == 'user' && selectedProductsHints == '0 REHINTS') {
$('.info').css('display', 'none');
} else {
$('.info').css('display', 'inline');
selectedProductsInfo = selectedProductsHints;
}
Debugging is showing in the case there are hints it should assign it here: 如果有提示应在此处分配调试,则会显示调试信息:
<div class="rehints">10 REHINTS</div>
In the case where I run the code below. 如果我运行下面的代码。 the debugger looks like it's finding out that it does have hints an assigning 2 HINTS to the div: 调试器看起来好像发现确实有向div分配2提示的提示:
But the result still shows 10 REHINTS: 但是结果仍然显示10条提示:
What am I doing wrong? 我究竟做错了什么?
If you change this line: 如果更改此行:
selectedProductsInfo = selectedProductsHints;
to: 至:
viewHint.querySelector('.rehints').textContent = selectedProductsHints;
It should achieve what you are going for. 它应该实现您的目标。
This got it working: 这使其工作:
var selectedProductsHints = a.clones + ((a.clones == 1)? " REHINT" : " REHINTS");
if(pathsArray[1] == 'user' && selectedProductsHints == '0 REHINTS') {
$('.info').hide();
} else {
$('.info').show();
$("div.rehints").text(selectedProductsHints);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.