JavaScript/jQuery - grabbing an integer from an element's id

前端 未结 10 639
青春惊慌失措
青春惊慌失措 2021-01-18 20:55

From the following markup.


      
10条回答
  •  不要未来只要你来
    2021-01-18 21:56

    As long as the preceding text always remains the same you can just use the substring method to get the number.

    $(this).attr('id').substring(5)
    

提交回复
热议问题