开发者

Problem with Display of jQuery Menu

Menu does not display in line. Not sure how to call the CSS code. Also I want the alert to tell me which menu item was clicked.

<script type="text/javascript">
function get_list() {
   $("#tabs").click(function(){
           $(this).click(function(){
              alert(this); 
           });
   });
</script>


<style type="text/css">
#navbarID li {
    display: inline;
}
</style>


</head>  
<body>  

<div id="tabs">
     <ul>
             <li><a href="type1.html">Type 1</a></li>
             <li><a href="type2.html">Type 2&开发者_如何学JAVAlt;/a></li>
             <li><a href="type3.html">Type 3</a></li>
     </ul>
</div>

</body> 
</html>


the html should be something like this.

<ul id='tabs'>
<li><a href='type1.html'>Type 1</a></li>
<li><a href='type2.html'>Type 2</a></li>
<li><a href='type3.html'>Type 3</a></li>
<li><a href='type4.html'>Type 4</a></li>
</ul>

the css part could be this:

    ul#tabs { list-style: none; }
    ul#tabs li { display: inline; }

the onclick that you want on jQuery is like this:

 $('ul#tabs li a').click(function(){ alert('i was clicked!'); return false; });


alert($(this).html()); will tell you what the contents of that nav item are.
Maybe you should use <span> instead of <div> for inline.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜