We help IT Professionals succeed at work.

Hiding a div based on if condition using jquery

1,741 Views
Last Modified: 2017-11-21
Hi,

I am new here. I was working on jsp pages and looking forward to implement a hiding function for a division based on if condition as shown below code:

<c:forEach items="${roleMapList}" var="item">
<c:if test="${item.rolemaproleid == 1 && item.rolemaproleid == 2 && item.rolemaproleid == 3}">
                           
/*  Here I have to implement code (jquery/javascript) to disable a div having an id= "hidingDiv"  */
                           
</c:if>
</c:forEach>

Could you please help me to surve for this day
Comment
Watch Question

Jim RiddlesPrepress/OMS Specialist
CERTIFIED EXPERT

Commented:
If it is a single DIV with a known id, then it would be as simple as the following:

$('#hidingDiv').hide();

Open in new window

CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
How is this ever going to evaluate to true
{item.rolemaproleid == 1 && item.rolemaproleid == 2 && item.rolemaproleid == 3}

Open in new window


Consider
x = 1
if (x==1 && x==2 && x==3) {
   "I will give you $1M";
}

Open in new window

IT Expert
CERTIFIED EXPERT
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Hi  @Michel Plungjan

 Thanks for your solution, which is working absolutely fine. Actually the loop is only to hide the div, but I want to hide if item is 1,2 AND 3. Could you please suggest me.
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
I ask again under what conditions is this ever possible?
{item.rolemaproleid == 1 && item.rolemaproleid == 2 && item.rolemaproleid == 3}

Open in new window

How can something be 3 different things at the same time?
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.