下面是我用来允许点击下拉列表以显示下面相应div的脚本。我似乎无法绕过它。该列表由mysql查询生成。我一直试图在我的脚本中使用“this”,但无济于事(抱歉还是jobery的菜鸟)。任何建议都会很棒。我故意忘记了脚本标签。
$(document).ready(function() {
$("#menu['Prosub1']").click(function(event){
event.preventDefault();
$('#content .container').hide();
$('#container'.attr('id') ).show();
});
});
<div id="Pagecontainer">
<div class="mainmenu">
<ul>
<li id="menubar">Products
<ul>
<?php
foreach ($gbpro->query($gbpro1) as $menu) {
echo "<li id=".$menu['Prosub1'].">". $menu['Prosub1'] . "</li>";
}
?>
</ul>
</li>
<li>Services
<ul class="list_items">
<?php
foreach ($gbpro->query($gbserv1) as $menu) {
echo "<li data-target=".$menu['Servsub1']." id=".$menu['Servsub1'].">". $menu['Servsub1'] . "</li>";}
?>
</ul>
</li>
<li>About
<ul class="list_items">
<?php
foreach ($gbpro->query($gbabout1) as $menu) {
echo "<li data-target=".$menu['aboutsub']." id=".$menu['aboutsub'].">". $menu['aboutsub'] . "</li>";}
?>
</ul>
</li>
</ul>
</div>
</div>
<div id="content">
<div class="container" id="Laptops">
this is laptops content
</div>
<div class="container" id="Tablets">
this is Tablets content
</div>
<div class="container" id="Computers">
this is computer accessories content
</div>
</div>