我想过滤逗号分隔字符串(列值)中的确切单词
例如
字符串 : [CST,CS,ATS,ALU]搜索输入 : CS
这里
我需要只有 CS 而不应该有 CST 的行列表。
你能帮我解决这个问题吗?
谢谢
您可以执行以下操作:
// 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