Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If div value equals '1' hide another div

I have a div that loads in the number of images on each page. For example:

<div class="totalimages">1</div>
<div id="arrows">NEXT</div>

When I have one image, i'd like to hide the #arrows div. I'm not very good with jQuery so I was wondering what the syntax would be for it to be,

IF the .totalimages div equals '1' then HIDE the div #arrows.

Thank you!

like image 367
Laura Avatar asked Nov 23 '25 07:11

Laura


1 Answers

Try this:

if ($(".totalimages").text() == "1") {
    $("#arrows").hide();
}

or in one line:

$("#arrows").toggle($(".totalimages").text() != "1");
like image 152
VisioN Avatar answered Nov 24 '25 22:11

VisioN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!