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 01-18-2010, 11:09 AM   PM User | #1
forcerhpool
Regular Coder

 
Join Date: Jun 2007
Posts: 126
Thanks: 4
Thanked 0 Times in 0 Posts
forcerhpool is an unknown quantity at this point
jQuery SlideDown

I am new to jQuery but am using it to SlideDown a DIV element when the
a:link is clicked.

However, no matter what link i click on the page, it slides down the
div, it's as if the script has taken over every link on the page.

Here is the code:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
var $div = $('#alias-box');
var height = $div.height();
$div.hide().css({ height : 0 });

$('a').click(function () {
if ($div.is(':visible')) {
$div.animate({ height: 0 }, { duration: 250, complete:
function () {
$div.hide();
} });
} else {
$div.show().animate({ height : height }, { duration:
250 });
}

return false;
});
});
</script>


html:

<a href="#alias-box" style="font-size:10px;">Custom Alias</a>
<div id="alias-box"><input name="new_alias" class="field_50"
type="text" /></div>


so clicking Custom Alias, drops the 'alias-box' div.

But even when i click other links such as:

<a href="contact.php">Contact</a>

it ignores going to contact.php and displays the div.

Any ideas how to fix this?
forcerhpool is offline   Reply With Quote
Old 01-18-2010, 11:15 AM   PM User | #2
seco
Regular Coder

 
seco's Avatar
 
Join Date: Nov 2008
Location: Oregon
Posts: 682
Thanks: 5
Thanked 79 Times in 77 Posts
seco has a little shameless behaviour in the past
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {

$("#alias-box").click(function () {
$("#alias-div").slideToggle("slow");
});

});
</script>

html:

<a id="alias-box" href="#" style="font-size:10px;">Custom Alias</a>
<div id="alias-div" style="display:none;"><input name="new_alias" class="field_50"
type="text" /></div>

Last edited by seco; 01-18-2010 at 11:19 AM..
seco is offline   Reply With Quote
Old 01-18-2010, 12:25 PM   PM User | #3
forcerhpool
Regular Coder

 
Join Date: Jun 2007
Posts: 126
Thanks: 4
Thanked 0 Times in 0 Posts
forcerhpool is an unknown quantity at this point
works a treat and so much simpler.

thanks
forcerhpool 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 03:37 PM.


Advertisement
Log in to turn off these ads.