2011-07-14 25 views

回答

1

雖然一些你的HTML代碼,將不勝感激,這裏是一個基本的實現。

$('form').submit(function() { 
    var attributeToSearch = $('.search').val(); 
    $('table tr[uniqueAttribute="' + attribute + '"]').css('background', 'red'); 
}); 

的HTML應該是這樣的:

<table> 
    <tbody> 
     <tr uniqueAttribute="foo">...</tr> 
     <tr uniqueAttribute="bar">...</tr> 
    </tbody> 
</table> 

而且形式:

<form> 
    <fieldset> 
     <input type="text" class="search" /> 
     <input type="submit" /> 
    </fieldset> 
</form> 

在表單提交,我們檢查用戶輸入的輸入和搜索錶行它具有該屬性值並更改其背景。

相關問題