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
Post a Comment