2013-10-07 21 views
0

我要篩選以逗號分隔的字符串完全匹配的字詞(列值)jQuery的數據表,以逗號分隔的字符串搜索一個確切的詞(未子串)(列值)

例如,

字符串:[CST,CS,ATS,ALU] 搜索輸入:CS

這裏,

我需要的只有CS,不應該有CST排列表。

你能幫我解決這個問題嗎?

感謝

+1

什麼是你的代碼看起來像那麼遠?你有一套測試數據嗎? CTS和CS是唯一的標準是互斥的嗎? –

回答

2

你可以做到以下幾點:

// array declaration 
    var stringArray = ["CST", "CS", "ATS", "ALU"]; 
    // using jQuery.inArray gives us the position of the item 
    var indexFound = $.inArray("CS", stringArray); 
    // put the item found on that index on the variable 'itemFound' 
    var itemFound = stringArray[indexFound]; 

我希望這是你需要什麼,this is my first help here! :P

+0

歡迎來到StackOverflow!請記住,您的用戶名不是永久性的,您可以在喜歡 –

+1

時更新它。謝謝@NewAlexandria。 –

相關問題