我有这个链接:
<a id = "link_1" href = "#">Cars</a>
<a id = "link_2" href = "#">Colors</a>
<a id = "link_3" href = "#">Users</a>
<a id = "link_4" href = "#">News</a>
如何获取我点击的身份证号码?例如,我推送链接汽车,我希望得到1,推送用户,得到3号。
谢谢
发布于 2010-09-19 02:27:28
这样就可以了:
$('a').click(function(){
alert(this.id.split("_")[1]);
});
发布于 2010-09-19 02:29:01
$("a").click(function(event) {
event.preventDefault();
var theid = $(this).attr("id").split("_");
theid = theid[1]; //here is the number
}
发布于 2010-09-19 04:01:55
$(function() {
$('a').click(function() {
var id = $(this).attr('id');
alert(id.match(/\d+/)[0];
});
});
https://stackoverflow.com/questions/3742907
复制相似问题