jquery从ID获取数字 [英] jquery get number from id

查看:126
本文介绍了jquery从ID获取数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从一个div标签的id获取数字?

例子:

 < div id =button1>< / div> 

如何获得1并将其存储在变量中?

var id = $(div)。attr('id')。replace(/ button /,' );


how can i get the number from a div tag's id?

example:

<div id="button1"></div>

how can i get the 1 and store it in a variable?

解决方案

var id = $("div").attr('id').replace(/button/, '');

这篇关于jquery从ID获取数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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