javascript - Error getting the .last() -


i have this structure

i want last message, im trying use .last() function:

$('#user-chat-' + data.de).find('#load-msgs').last().html() 

but jquery returns results inside div, not last result. knows why im getting error? (the selector correct, im getting result, don't last) thanks!

    $(document).ready(function(){             $("#load-msgs").last().find('div span').html()  //or            $("#load-msgs div span").last().html()         }) 

here working fiddle

the html script :

<div class="row" id="load-msgs">     <div class="col-md-10 col-sm-12 col-xs-12 ">         <span class="message-box message-other" data-toggle="tooltip" data-placement="right" title="18:28">          lewpwa </span>     </div>       <div class="col-md-10 col-sm-12 col-xs-12 ">         <span class="message-box message-other" data-toggle="tooltip" data-placement="right" title="18:28">          oppa   </span>     </div>       <div class="col-md-10 col-sm-12 col-xs-12 ">         <span class="message-box message-other" data-toggle="tooltip" data-placement="right" title="18:36">          oppa   </span>     </div>       <div class="col-md-10 col-sm-12 col-xs-12 ">         <span class="message-box message-other" data-toggle="tooltip" data-placement="right" title="18:36">          oppa   </span>     </div></div> 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -