Cannot select and copy value of html element using jQuery -


i need copy value 1 div input. when trying display selected value shows undefined. why?

<div class="thumbnail" id="thumbnail2">       <div class="book author"> author 1 </div>  </div>  

--

// $('#author').val(   $('#thumbnail'+id+' .author').val()            ); // copy alert (   $('#thumbnail'+id+' .book .author').val() ); // displays 'undefined' 

take out space between .book , .author (you selecting element class 'author' child of element class of 'book') , use text() not val(), so

alert($('#thumbnail'+id+' .book.author').text());


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -