我的每个id为 id1、id2、id3….
每次我需要拿到id后面跟的数字
<!-- 简单写几个按钮 --> <div class="btn-box"> <button id="btn1">按钮1</button> <button id="btn2">按钮2</button> <button id="btn3">按钮3</button> </div>
<script>
// 当点击时,我要拿到对应id后面拼接的数字来判别执行的事件
$(".btn-box button").click(function(){
var IdKey = $(this).attr('id').replace(/[^0-9]/ig,"");
console.log(IdKey);
})
</script>
