Commit 8cbf7cb5 authored by Muhammad Ameen's avatar Muhammad Ameen 💻

some conditions add

parent 71e4de7d
let searching = document.getElementById("searching"); let searching = document.getElementById("searching");
let count = document.getElementById("count"); let count = document.getElementById("count");
let input = document.getElementById("input"); let input = document.getElementById("input");
var num = 0; let num = 0;
let preValVar = "";
function debounce() { function debounce() {
if (input.value?.length > 0) { if (input.value.length > 0) {
let x = setTimeout(() => { let x = setTimeout(() => {
console.log("Muhammad Amenn"); if (input.value !== preValVar) {
searching.style.display = "block"; console.log(input.value == preValVar);
num++; num++;
count.innerHTML = num; count.innerHTML = num;
preValVar = input.value;
}
}, 1000); }, 1000);
clearTimeout(x - 1); clearTimeout(x - 1);
} }
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
placeholder="Search Here" placeholder="Search Here"
id="input" id="input"
/> />
<p class="count" id="searching">Api Hit <span style="color: red; font-size: 30px;" id="count">0</span></p> <p class="count" id="searching">API Hit <span style="color: red; font-size: 30px;" id="count">0</span></p>
</div> </div>
<script src="./app.js"></script> <script src="./app.js"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment