Show or hide div with javasript

I am using JavaScript like the below to check an ID. It hits a query and returns true or false. If it returns "false" I want to show a DIV If it returns "true", I want to hide that same div. x is the variable that gets returned. In the example below I am just showing "x". I'd like to replace that with the show/hide of the div I described above. Can someone assist? Thank you.

<script language="javascript">
      function CheckIt(ID){
      var cfcAsAjax = new jsobj();
    x = cfcAsAjax.CheckIt(ID);
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
should be:
if (x==true) {
} else {

Open in new window

Guy Hengel [angelIII / a3]Billing EngineerCommented:
using jQuery: use slotToggle() function makes it very easy
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sorry... based on a function. well, you can ignore my comment...
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Albert Van HalenAnalyst developerCommented:
Alternatively you can use display instead of visiblity.

Both will hide the element but setting visibility to hidden reserves the place of the element so you will end up with a 'gap' in your UI.
Have a look here;
It illustrates the difference between the two.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
earwig75Author Commented:
Should I use display none to avoid it? I'd prefer that...
Albert Van HalenAnalyst developerCommented:
To avoid the gap? Yes, you should use display and set it to none.
In order to show it should set display to inline or block.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.