我也想为每个州和每个城市设置一个链接。当状态 li 悬停在我只希望这个状态城市显示....但我只知道一点 jquery 代码并且我对选择器的理解并不完美,我不确定如何使用 .each jquery 函数.... 请帮忙!!!!php代码:
<?
$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>