7
In pure javascript I can use indexOf()
, something like that:
var chaves = ['wmv','3gp','mp4','mp3','avi'];
if(chaves.indexOf("avi") != -1)
{
alert("Ok!");
}
But in the case of a search ground I’m trying this way:
<html>
<body>
<input type="text" id="txt" onblur="verifica()"/>
</body>
<script>
var chaves = ['wmv','3gp','mp4','mp3','avi'];
var item = document.getElementById('txt').value;
function verifica() {
for(var i = 0; i < chaves.length; i++)
{
if(chaves[i].length == item) {
alert("SIM")
} else {
alert("NAO")
}
}
}
</script>
</html>
The worst thing is I’ve done it once and now I can’t remember anymore. if anyone can help me.
Thanks for sharing!
– Diego Henrique