This question already has answers here:
get element value using jquery
                                
                                    (2个答案)
                                
                        
                6年前关闭。
            
        

<span id="rate">2388</span>

var = $("#rate")...


我需要获取元素内的数字值。有人知道该怎么做吗?

最佳答案

var number = +$("#rate").text();
//           |              \______get text of span as string
//           |_________________unary plus converts to numeric

关于javascript - Javascript/jquery获取元素内的数字值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21347393/

10-12 03:42