Can someone help me over this please. I have this piece of code:
$("#infocontent-northamerica").hide();
$("#infocontent-northamerica div").hide();
$('#linkwrapper-northamerica a[id]').click(function(){
var vsubmen = this.id +"content";
if( $("#infocontent-northamerica").is(":visible") == false ) {
$("#" + vsubmen).show('fast',function() {
$("#infocontent-northamerica").slideDown();
});
} else if ( $("#" + vsubmen).is(":visible") == false ) {
$("#infocontent-northamerica").slideUp('slow',function(){
$("#infocontent-northamerica div").hide();
$("#" + vsubmen).show();
$("#infocontent-northamerica").slideDown('slow');
});
} else {
$("#infocontent-northamerica").slideUp('slow',function(){
$("#infocontent-northamerica div").hide();
});
}
return false;
});
I am repeating this 4 times, cause instead of #infocontent-northamerica
I am using also for europe, latinamerica and asia. I know that this can be simplified with .each()
with defined array, something like this:
var arr = { "europe", "northamerica", "latinamerica", "asiapacific" };
$.each(arr, function() {
});
But I am not sure how to completely make this work. Any answer will be really helpful ...
Edit:
Linkwrapper div:
<div id="linkwrapper-northamerica">
<a id="link11" href="#">St. Petersburg, FL</a>
<a id="link12" href="#">Raleigh, NC</a>
<a id="link13" href="#">Winchester, KY</a>
<a id="link14" href="#">Somerset, NJ, HQ</a>
<a id="link15" href="#">Philadelphia, PA</a>
<a id="link16" href="#">Woodstock, IL</a>
<a id="link17" href="#">Middleton, WI</a>
</div><!-- end of linkwrapper -->
<div id="infocontent-northamerica">
<div class="midleft" id="link11content">St. Petersburg, FL</div>
<div class="midleft" id="link12content">Raleigh, NC</div>
<div class="midleft" id="link13content">Winchester, KY</div>
<div class="midleft" id="link14content">Somerset, NJ, HQ</div>
<div class="midleft" id="link15content">Philadelphia, PA</div>
<div class="midleft" id="link16content">Woodstock, IL</div>
<div class="midleft" id="link17content">Middleton, WI</div>
</div><!-- end of infocontent -->
When you click on anchor, div is showed with name of the city from infocontent div. Its all the same for asia, europe and latin america
$()
is not a variable.. – rlemon Jan 23 '12 at 15:37