JQuery How to extract value from href tag?

前端 未结 6 1162
野性不改
野性不改 2020-12-01 02:20

I am new to JQuery.

If I have the following tag. What is the best JQuery method to extract the value for \"page\" from the href.



        
6条回答
  •  情深已故
    2020-12-01 02:45

    The first thing that comes to my mind is a one-liner regex:

    var pageNum = $("#specificLink").attr("href").match(/page=([0-9]+)/)[1];
    

提交回复
热议问题