/    Sign up×
Community /Pin to ProfileBookmark

JQuery toggle(drop) problem.

Hi all,

Im really stumped so if anyone is any good with jquery i could really use your help! Im trying to get elements to display only one at a time using ‘toggle’ (so that if a user clicks one link it toggles some info in a div, a different link toggles diferent info and hides the first set of info etc… if u catch my drift!)

I have managed to acheive this with the code below:

[CODE] <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-type” content=”text/html; charset=utf-8″ />
<title>Fade Slider Toggle jQuery Plogin</title>

<link rel=”stylesheet” href=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css” type=”text/css” media=”all” />
<link rel=”stylesheet” href=”http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css” type=”text/css” media=”all” />
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js” type=”text/javascript”></script>
<script src=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js” type=”text/javascript”></script>
<script src=”http://jquery-ui.googlecode.com/svn/tags/latest/external/bgiframe/jquery.bgiframe.min.js” type=”text/javascript”></script>
<script src=”http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js” type=”text/javascript”></script>
<script src=”http://jqueryui.com/demos/toggle/js/demos.js” type=”text/javascript”></script>
<script src=”http://jqueryui.com/demos/toggle/themeroller/themeswitchertool/” type=”text/javascript”></script>

<script type=”text/javascript”>
$(document).ready(function(){
//hides everything
$(“#infocontent *”).hide();

//now we show them by which they click on
$(“#linkjoedhit”).click(function(event){
$(“#infocontent *”).hide();
$(“#infojoedhit”).toggle();
return false;
});

$(“#linkgarykhit”).click(function(event){
$(“#infocontent *”).hide();
$(“#infogarykhit”).toggle();
return false;
});

});
</script>

<style>
.xx { width: 240px; height: 135px; padding: 0.4em; position: relative; background-color:#FF0000 }
</style>
</head>
<body>

<a id=”linkjoedhit” href=””>Joe</a><br/>
<a id=”linkgarykhit” href=””>Gary</a>

<div id=”infocontent”>
<div id=”infojoedhit” class=”xx”>Information about Joe</div>
<div id=”infogarykhit” class=”xx”>Information about Gary</div>
</div>

</body>
</html>[/CODE]

However, i want to add a jquery effect (drop effect) – which i know can be done [see here: [url]http://jqueryui.com/demos/toggle/][/url]. To do this i tried:

[CODE]<script type=”text/javascript”>
$(document).ready(function(){
//hides everything
$(“#infocontent *”).hide();

//now we show them by which they click on
$(“#linkjoedhit”).click(function(event){
$(“#infocontent *”).hide();
$(“#infojoedhit”).toggle(drop);
return false;
});

$(“#linkgarykhit”).click(function(event){
$(“#infocontent *”).hide();
$(“#infogarykhit”).toggle(drop);
return false;
});

});
</script>[/CODE]

Unfortunatly this didn’t work. Can anybody help me to get it working?

Thanks loads in advance
[ps i have left the javascript refs in the code above so you can see what im using – it should all be fine its the same as being used on the example page i cited]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @mastubbs spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...