jQuery如何从href标记中提取值? [英] JQuery How to extract value from href tag?

查看:168
本文介绍了jQuery如何从href标记中提取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JQuery的新手.

I am new to JQuery.

如果我有以下标签.最好的JQuery方法是什么 从href中提取网页"的值.

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

<a href="Search/Advanced?page=2">2</a>

马尔科姆

推荐答案

我想到的第一件事是单线正则表达式:

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

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

这篇关于jQuery如何从href标记中提取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆