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

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

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