Updating div with jQuery not showing on DOM

David Tunnell

Some html that is always on the page.

            <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

        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:

enter image description here

But the result still shows 10 REHINTS:

enter image description here

What am I doing wrong?

David Tunnell

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);
        }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related