jquery - how get target children id -


short english...

my html

<button><span id="popmain"> pop </span></button>  $(document).bind({ click : function(evt){ var targetid = evt.target.id; var nodename = evt.target.nodename; } 
  • click event chrome ( nodename : span )
  • click event explorer (nodename : button)

when use explorer, want span's id.

i try

$(this).find('span').attr('id'); $(this).find('span').id; $("#"+evt.target.id).children('span').attr('id'); $("#"+evt.target.id).find('span:first-child').attr('id'); $("#"+evt.target.id).find('span:last-child').attr('id'); 

but result 'undifined'. t^t plz me...

spelling mistake:

$(this).find('span').attr('id'); $(this).find('span').id; $("#"+evt.target.id).childeren('span').attr('id'); // children not childeren. $("#"+evt.target.id).find('span:first-child').attr('id'); $("#"+evt.target.id).find('span:last-child').attr('id'); 

Comments

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -