點擊不同按鈕出現(xiàn)的提示不一樣
<body> <input?type="button"?> <input?type="button"?> <input?type="button"?> </body>
假設(shè)這么些個按鈕,要求點擊第二個按鈕,出現(xiàn)提示是:這是第二個按鈕。要怎么獲取到這個第幾個?小白求大神指教
<body> <input?type="button"?> <input?type="button"?> <input?type="button"?> </body>
假設(shè)這么些個按鈕,要求點擊第二個按鈕,出現(xiàn)提示是:這是第二個按鈕。要怎么獲取到這個第幾個?小白求大神指教
2017-06-27
舉報
2017-06-28
$(document).on('click','input',function(){
? ? var num=$(this).index()+1;
alert("您點擊的是“+num+“按鈕”);
})
我想到的是索引值加1 得到相應(yīng)的按鈕
2017-06-27
$('input').eq(1)