i would like too set a link for every state ,and every city.
when the state li is hovered over i only want that this states cities to show ….
but i kno only a little jquery code and im not perfect with understanding the selectors,
im not to sure on how to use the .each jquery function…. please help!!!!
php code:
<?
$everything = array(
'states'=>array(
'Alabama'=>array('Birmingham,Montgomery,Mobile,Huntsville,Tuscaloosa'),
'Alaska'=>array('Anchorage,Juneau,Fairbanks,Sitka,Ketchikan'),
'Arizona'=>array('Phoenix,Tuscon,Mesa,Glendale,Scottsdale'),
'Arkansas'=>array('Little Rock,Fort Smith,North Little Rock,Fayetteville,Jonesboro'),
)
);
$id = md5(0);
$controll = 0;
$here = md5('states');
echo "<div id=\"9090\"><ol id=\"selectable\">";
foreach($everything['states'] as $state=>$city){
$citys = explode(',',$city[0]);
echo "<li class=\"ui-state-default\"><a class=\"contr\" href=\"#\">$state</a> <div class=\"citys\">";
foreach($citys as $key=>$x){
echo "<a href=\"#\">$x</a><br>";
}
"</div></li>";
}
echo "</ol></div>";
?>
jquery :
<script>
$(function() {
$( "#selectable" ).selectable();
});
$('.ui-state-default').mouseenter(function(e) {
// here when i hover over this state all citys show i just want the cities for this sate
$('.citys').toggle();
}).mouseleave(function(e) {
// here when i leave this state li all theese citites should leave
$('.citys').toggle();
});;
</script>
You need to add context when finding the cities, like this
$('.citys', this).toggle();This will search for
.cityselements located insidethiswhich in this case is the hovered.ui-state-defaultelement.See how to use the context parameter at http://api.jquery.com/jquery/#jQuery1
Alternatively you can use
.find()