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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -