gpt4 book ai didi

javascript - Jquery 搜索 - 不按预期工作

转载 作者:行者123 更新时间:2023-11-30 13:16:50 25 4
gpt4 key购买 nike

这是我的示例代码: http://jsfiddle.net/pT6dB/

我有点问题。那里有两个示例答案:

“地球有多圆?”和“纸有多长?”

如果我输入搜索词“round Earth”,我希望它显示“How round is the Earth?”结果却没有。

我认为我需要更改查询,使其表示哪些问题同时包含“圆形”和“地球”。

这会是一个简单的修改吗?这是来自网站的示例代码,所以我不知道从哪里开始。

最佳答案

$('#search').keyup(function(e) {
var s = $(this).val().trim();

// show all results
$('#result LI').show();

// split the search into words
var keywords = s.split(' ');

// loop over the keywords and if it's not in a LI, hide it
for(var i=0; i<keywords.length; i++) {
$('#result LI:not(:contains('+keywords[i]+'))').hide();
}
});

关于javascript - Jquery 搜索 - 不按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11717681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com