jQuery increment value of tag

后端 未结 7 765
小鲜肉
小鲜肉 2020-12-31 04:12

I have a number in a span tag. I need to get the value of the number in the span and then increment it inside jQuery. I know how to do this for a text input - can this be

7条回答
  •  借酒劲吻你
    2020-12-31 04:35

    Something like this:

    var $span = $('#mySpanId');
    $span.text(Number($span.text()) + 1);
    

    http://jsfiddle.net/mattball/Cf834/

提交回复
热议问题