Solved

Enlarging a Div

Posted on 2013-12-29
4
341 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
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 …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now