Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-04-2011, 02:45 PM   PM User | #1
leetvivi
New Coder

 
Join Date: Feb 2011
Posts: 12
Thanks: 1
Thanked 1 Time in 1 Post
leetvivi is an unknown quantity at this point
Hiding a div (picture) and still holding its position

Completely new to jQuery / Javascript, so sorry if I'm not very clear.

I'm currently trying to hide my navigation button when it hides the end of the list, right now I currently have:

Previous / Next (they are about the same anyways)
Code:
function previousEvent(i) {
        var k = new Number(i);
        if (index == 0) {
            $('#previous').hide();
        }

        else {
            $('#next').show();
            index = index - 1;
            eventSelected(rawDates[index], rawTime[index]);

        }
    }
And in my html...the div properties:

Code:
<div style="text-align:right;">
                        <div id="next" style="float:right;"><a onclick="javascript:nextEvent();">
                        <input type="image" name="next" src="images/SiteCollectionImages/MiniEvents/btn_Next.gif" alt="Next Event" title="Next Event"/></a>
                        </div>
                        <div id="previous" style="float:right; padding-right:2px;"><a onclick="javascript:previousEvent();">
                        <input type="image" name="previous" src="images/SiteCollectionImages/MiniEvents/btn_Previous.gif" alt="Previous Event" title="Previous Event"/></a>
                        </div>
edit:
Sorry forgot to explain, I'm trying to make it so when they click on next, and keep clicking until the end of the dataset, it will hold the previous button where it usually is. Instead right now it moves it over to where the "Next" button is. I figured there has to be a way to hide the button, but yet hold the position still.

Thanks in advance!

Matt
leetvivi is offline   Reply With Quote
Old 02-04-2011, 04:02 PM   PM User | #2
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
If you give an element display: none (and that's what's actually happening inside hide()), it will be removed from the document flow, and the positions of other elements will change. If you want a hidden element to stay in the flow and retain its position, use visibility: hidden instead.

So, instead of $(yourElement).hide() you do $(yourElement).css({visibility: 'hidden'}), and instead of $(yourElement).show() you do $(yourElement).css({visibility: 'visible'}).
venegal is offline   Reply With Quote
Users who have thanked venegal for this post:
leetvivi (02-04-2011)
Old 02-04-2011, 04:21 PM   PM User | #3
leetvivi
New Coder

 
Join Date: Feb 2011
Posts: 12
Thanks: 1
Thanked 1 Time in 1 Post
leetvivi is an unknown quantity at this point
venegal, I cannot thank you enough!
I was literally ripping my hair out over this easy one liner of code

Thanks!!
leetvivi is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:49 PM.


Advertisement
Log in to turn off these ads.