Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Enlarging a Div

Posted on 2013-12-29
4
Medium Priority
?
355 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 2000 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

971 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