javascript - Call a function when any anchor tag inside a div is clicked -


i have menu like

<div class="nav_bar" style="background: url(../images/nav.jpg) repeat scroll 0px 0px transparent;">             <div id="navid" class="ddsmoothmenu">                 <ul id='ul2'>                             <li id='li6'><a href="inner.php" title="home">home </a>                               </li>                   </ul>                <ul id='ul4' >                <li id='li1' ><a href="#" title="master">car </a>                     <ul>                     <li id='li10'><a href="#" title="plan type">fuel</a>                     <ul>                                                           <li id='li10' ><a href="petrol.php" title="petrol">petrol  </a> </li>                         <li id='li10' ><a href="diesel.php" title="diesel">diesel  </a></li>                                   </li>                     </ul>                     </li>                  </ul>                   </li>                </div>   </div> 

is possible call event or function click in anchor tag within div nav_bar? have tried

$(".nav_bar #navid").click(function(e) {     alert("hai");      });   

but doesn't work

thanks in advance

since nav_bar class, not id, should this:

$('.nav_bar a').click(function(){     alert("clicked"); }); 

working fiddle: http://jsfiddle.net/gs3kj/


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -