javascript - Updating the content of a div using jquery waypoints -
i using waypoints.js
in html given below, when waypoint of hardware
class reached should update content of <div>
having class number
content of div.current
within div.hardware
.
my html:
<div class="number"></div> <div class="hardware"> <div class="current">1</div> </div> <div class="hardware"> <div class="current">2</div> </div> <div class="hardware"> <div class="current">3</div> </div> <div class="hardware"> <div class="current">4</div> </div>
i have this:
$(function() { $('.hardware').waypoint(function() { var addnumber = $(this).find('.current').content(); $('.number').content(addnumber); }); });
but doesn't work me.
the jquery method contents()
, not content()
$(function() { $('.hardware').waypoint(function() { var addnumber = $(this).find('.current').contents(); $('.number').contents(addnumber); }); });
p.s: contents()
method retrieves comment nodes. getting text content element, it's better use text()
method.
Comments
Post a Comment