jquery - Knockout JS - Value of span -
my application mvc5; trying value of knockout span using following: <span id="total" data-bind="text: allimages().length"> </span> i see 10 on screen correct value. tried use: var total = $('.total').text(); alert(total); don't value, tried .val(). edit can value if use function: function getvalue() { var total = $('#total').text(); $('#mytext').val(total); alert(total); } is there way value onchange of span text? you need $('#total') , not $('.total') #total finds element id, correct html span id; .total means classname, , there no div in code class, it's correctly matching no elements.