0

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?

1
  • 1
    use .show() / .hide() instead of .css('display') Commented Nov 25, 2015 at 20:10

2 Answers 2

1

If you change this line:

selectedProductsInfo = selectedProductsHints;

to:

viewHint.querySelector('.rehints').textContent = selectedProductsHints;

It should achieve what you are going for.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.