javascript - Twitter Bootstrap dropdown determine what element is clicked -


i have following code:

<div id="dropdown" class="btn-group">     <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">       dropdown       <span class="caret"></span>     </button>     <ul class="dropdown-menu">       <li><a href="#">dropdown link 1</a></li>       <li><a href="#">dropdown link 2</a></li>     </ul>   </div> 

i clicking on link. how can determine link clicked?

$("#dropdown").click(function(e) {   console.log(e);   //how??  }); 

i using jquery.

you should able use this:

$('.dropdown-menu > li > a').on('click', function(e) {     e.preventdefault(); //disable href     window.alert($(this).text()); //$(this).text() want }); 

update: demo here


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -