Solved

Enlarging a Div

Posted on 2013-12-29
4
347 Views
Last Modified: 2013-12-29
When I click on a link I am trying to get a div to enlarge.  The div is called "sidebox".  The website is www.mediascrubber.com  The div is the white box with the grey line around it.

<ul id="bars">
		<li><a href="#!/page_One">One</a><!-- Begin One -->
    	<li id="page_One">
			<div id="sidebox" class="sidebig">
			</div>
		</li>
    	</li><!-- End One -->
	</ul>

Open in new window


I want it to work like www.legalzoom.com
0
Comment
Question by:DS928
  • 2
  • 2
4 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39745060
This is based no jquery - I'm sure you can easily adapt it to your particular code
http://jsfiddle.net/GaryC123/6adEM/1/

HTML
<div id="container">
    <div class="buttons">
    <button id="but1">button 1</button>
    <button id="but2">button 1</button>
    </div>
    <div class="content">
    <span class="but1">some text</span>
    <span class="but2">some other text</span>
    </div>
</div>

Open in new window

CSS
#container {
    height:100px;
    width:100px;
    overflow:hidden;
    border:1px solid green
}
.buttons {
    width:90px;display:inline:block;float:left
}
.content span{
    width:90px;
    display:inline-block;
    float:left;
    display:none
}

Open in new window

JQUERY
$("#container").mouseenter(function(){
        $(this).animate({width: '200px'});
})
$("#container").mouseleave(function(){
        $(this).animate({width: '100px'});
})
$(".buttons button").hover(function(){
  $(".content ."+$(this).attr("id")).toggle()  
})

Open in new window

0
 

Author Comment

by:DS928
ID: 39745119
Your example works great.  Mine doesn't.  I copied all of the code and it doesn't seem to work.  Could it be my jquery version?

<script type="text/javascript" src="js/jquery-1.7.2.min.js" ></script>
<script>
		$("#container").mouseenter(function(){
        $(this).animate({width: '200px'});
		})
		$("#container").mouseleave(function(){
        $(this).animate({width: '100px'});
		})
		$(".buttons button").hover(function(){
  		$(".content ."+$(this).attr("id")).toggle()  
		})
</script>

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39745121
Wrap your script in

$(function() {
...
})

Open in new window

So it doesn't fire until the page has loaded and the elements exist, at the mo you have it before the html so they don't actually exist when the js is fired.
0
 

Author Closing Comment

by:DS928
ID: 39745138
Bingo!  That was it!  Thank you.
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Joomla 2.5 shopping cart 7 23
Why a span is lower 2 20
How to change the link of an image using md5 in php ? 3 33
Can't get second accordion on page to work 2 7
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question