点击按钮返回符合大于输入框中指定数字的数组元素索引。
最小年龄: <input type="number" >点我</button>

索引: <span ></span><

注意: IE 11 及更早版本不支持 findIndex() 方法。

var ages = [{a:4}, {a:12}, {a:16}, {a:20}];

function checkAdult(age,index) {
return age.a >= document.getElementById("ageToCheck").value;
}

function myFunction() {
document.getElementById("demo").innerHTML = ages.findIndex(checkAdult);
}

 

相关文章:

  • 2022-02-04
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案