搜索输入的文本是否存在于 select 列表中

Search if the inputed text exist in select list

我使用 prestashop1.7。按品牌搜索在模块 ps_facetedSearch.

中以“下拉列表”形式完美运行

我需要覆盖此搜索而不是下拉列表我需要一个输入字段,所以我认为解决方案可以是搜索下拉列表中是否存在输入的文本。这是我的文章,但尽管控制台登录了 txtValue 并输入了这些变量的 showContent,但控制台不显示。这就是为什么我需要你帮助脚本 js 本身,它必须测试输入的文本是否存在于下拉列表中。

分面搜索模块的代码 html

<div class="dropdown-menu" id="dropdown-menu">
   <a rel="nofollow" href="http://archivartshop.local/fr/2-accueil?q=Marque-Naim+Ameur" class="select-list"> Naim Am(1)</a>
 <a rel="nofollow" href="http://archivartshop.local/fr/2-accueil?q=Marque-Sonia+Mili" class="select-list"> Sonia Mili (1) </a>
   <a rel="nofollow" href="http://archivartshop.local/fr/2-accueil?q=Marque-Yosr+Ben+Hammouda" class="select-list"> Yosr Ben Houda(2)</a>
 </div>

我的论文脚本js

function mFn(){
  divLi = document.getElementById("dropdown-menu");
  linka = divLi.getElementsByTagName("a");
for (i = 0; i < linka.length; i++) {
var  txtValue = linka[i].textContent ;
  // console.log(txtValue); content displayed
  var inpted = $('#search_input').val();
  // console.log(inpted);content displayed

  if( txtValue === inpted)
  {

    console.log("it_works");

  }
else {
  console.log("No !!");
}
}

}

非常感谢你的帮助

现在对我有用

function mFn(){
  divLi = document.getElementById("dropdown-menu");
  linka = divLi.getElementsByTagName("a");
for (i = 0; i < linka.length; i++) {
var  txtValue = linka[i].textContent ;
  // console.log(txtValue); content displayed
  var inpted = $('#search_input').val();
  // console.log(inpted);content displayed

  if( txtValue.includes(inpted) )
  {

    console.log("it_works");

  }
else {
  console.log("No !!");
}
}

}