2012-08-10 34 views
0

我正在使用ibatis和jsp的spring mcv進行查看。 我的問題是在jsp頁面中,我正在查看一個數據表,其中包含一個按鈕,最後一列是從Spring控制器呈現的,如下面顯示的jsp頁面。如何更改按鈕的值

<c:forEach var="aff" items="${hotellistdisplay}"> 

<td width="auto" align="center" class="row2"><b> 
    <input type="button" name="mybutton" id="${aff.hotel_id}" class="view" value="Deactivate"> 
    </b> </td> 

存在包含按鈕10行,但作爲行的一個用戶點擊按鈕的值應當改變爲ACTIVE而不影響其它行按鈕。 雖然我得到了基於類的代碼,我正在更改值,但它也反映了所有其他按鈕。 我想價值應該改變爲特定的用戶點擊..

任何幫助PLZ。 謝謝。

回答

0

您仍然可以使用class屬性,而是使用this,而不是自己的函數中:

$(".view").click(function(){ 
    $(this).val("ACTIVE"); 
});​ 

演示HERE

+0

謝謝sir.it工程 – ASUR 2012-08-10 09:11:12

1

可以使用val()方法,請嘗試以下操作:

$('td input[type="button"]').click(function(){ 
    $(this).val('active') 
}) 

或:

$('tr td').click(function(){ 
    $('input[type="button"]', this).val('active') 
}) 
0
$('td').click(function(){ 
    $(this).find('input[type="button"]').val('ACTIVE'); 
})