請問如何把用filter篩選的資料拆開?
我的頁面有一個很多國家名稱的表格,需要增加一個快速查詢的功能,把查詢的資料用逗點隔開印出來我用filter是有把結果正確篩選出來,不過篩出來的資料全部連在一起,請問可以怎麼做呢?
p.s 之前沒用過jQuery所以亂拼亂湊下用了filter做篩選,不知道這樣的做法可不可行^^a[code]<script type="text/javascript">
$(document).ready(function(){
$(':button[name=filterButton]').click(function(){
var filterSection = $(this).parents('.FilterSection');
var FilterMessageText = filterSection.find('span.FilterMessageText'); //查詢條件
var FilterMessageResult = filterSection.find('span.FilterMessageResult'); //查詢結果
FilterMessageText.text(''); //清除篩選顯示訊息
FilterMessageResult.text('');
filterSection.find('input:text').each(function(){
condition = this.value
if(condition){
result = filterSection.find('tbody td').filter(function(){
return (new RegExp(condition).test(this.innerHTML)); //模糊比對
})
FilterMessageResult.append(result.text()) //顯示訊息
FilterMessageText.append(condition)
}
});
});
});
</script>[/code] 如果可以的話,把網頁一起傳來看看,這樣才不用猜測你的程式是在做什麼喔... [b]回復 [url=http://jsgears.com/redirect.php?goto=findpost&pid=1400&ptid=479]2#[/url] [i]wmh[/i] [/b]
之前是所有國家在一個表格裡,後來我把每個國家改成一個一排,所以排版的問題解決了:)
謝謝哩~
頁:
[1]