How to use div id and li together

How to use div id and li together

I have created a dropdown by dom element and I want to do on click id value will appear in alert.
I have tried this
  1. $(document).ready(function() {
  2. $('#dropList').click(function(){
  3. $('li').click(function(){
  4. var getmyId=$(this).attr('id');
  5. alert (getmyId);
  6. });
  7. });
  8. });
By this I am getting correct value but I have to click twice and alert appearing twice and thrice.
I have also tried this
  1. $(document).ready(function() {
  2. $('#dropList li').click(function(){
  3. var getmyId=$(this).attr('id');
  4. alert (getmyId);
  5. });
  6. });
But it's not working so what should I do now?