How to get numbers from the Paragraph tag?

前端 未结 2 1902
一生所求
一生所求 2021-01-25 00:02

I am having some values in my paragraph tag. I am trying to get the values from the paragraph tag. But I am unable to get the values. For example,

HTML Code:

<         


        
2条回答
  •  没有蜡笔的小新
    2021-01-25 00:36

    you want to do

    var value = $('#value').html();
    

    That should give you the value you're looking for. The html() function returns all the html code within the selector. In your case it's just the text.

    If you want that as a number instead of a string just wrap it in parseInt()

    var integer_value = parseInt($('#value').html());
    

提交回复
热议问题