我需要使用jquery檢索可點擊的按鈕的值。我有一個<div>
下的3個按鈕。使用jquery獲取輸入按鈕的值
<div class="button1">
<input type="button" value="one" id="One" onclick= "location.href='index.html'"/>
<input type="button" value="two" id="Two" onclick="location.href='index.html'" />
<input type="button" value="three" id="Three" onclick="location.href='index.html'" />
</div>
如果我點擊按鈕1,我需要一個按鈕1.我不知道究竟是如何得到這部分的價值中獲得價值。
這是我的js。
$(document).ready(function() {
$('.button1').click(function() {
var text = $(this).text();
$("input").val(text);
});
});
我知道這個js腳本我寫錯了。因爲我的價值觀是「一,二,三」。
在此先感謝。
耶工作的功能....謝謝你快速回答:-) – ssss05 2012-03-15 14:03:08