我正在做一个搜索引擎。在该模块中,我必须在菜单栏中选择城市。我从城市名称中取出城市名称到菜单栏。如果我选择一个特定的城市,我必须在该菜单中显示相同的内容。怎么做?帮助我...
<?php
$sql="SELECT DISTINCT CITY_ID,CITY_TITLE FROM CITY";
$res=mysql_query($sql);
?>
<header>
<nav class="headerTop">
<div class="container">
<div class="row">
<div class="headerTopHolder">
<div class="dropdown locationDropdown">
<a id="bangaloreclick" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Bangalore
<span class="glyphicon glyphicon-menu-down"></span>
</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" id="insideareas">
<?php while($cityrow=mysql_fetch_array($res)) { ?>
<li>
<a href="#"><?php echo $cityrow['CITY_TITLE'];?></a>
</li>
<?php } ?>
</ul>
</div>
答案 0 :(得分:0)
你是说这个?
$('#insideareas a').on("click",function(){
alert($(this).html())
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" id="insideareas">
<li><a href="#">City Name 1</a></li>
<li><a href="#">City Name 2</a></li>
<li><a href="#">City Name 3</a></li>
<li><a href="#">City Name 4</a></li>
</ul>