diff --git a/index.html b/index.html index c1f06d5..4a66efe 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@
- +
diff --git a/main.js b/main.js index 98f18e5..7624a7c 100644 --- a/main.js +++ b/main.js @@ -3,6 +3,13 @@ const form = document.querySelector("form") const button = document.querySelector("button") const input = document.querySelector("input") input.value="" +// button.addEventListener("click",()=>{ +// console.log(input.value.toUpperCase()) +// if(input.value == input.value.toUpperCase()){ +// console.log("uppercase") +// } +// }) + blog_data.forEach((e)=>{ let card = `
@@ -29,6 +36,36 @@ blog_data.forEach((e)=>{ ` mainRow.insertAdjacentHTML("beforeend",card) +input.addEventListener("input",()=>{ + + if(input.value == ""){ + mainRow.value = "" + let card = ` +
+
+
+
+
${e.title}
+ ${e.dec} +
Read more + +
Writing by: ${e.writingBy} @${e.writingBy} +
+ +
+
+ +
+
+
+
+ +
+ + ` + mainRow.insertAdjacentHTML("beforeend",card) + } +}) }) form.addEventListener("submit",(e)=>{ @@ -37,10 +74,41 @@ form.addEventListener("submit",(e)=>{ button.addEventListener("click",()=>{ + mainRow.innerHTML = "" blog_data.forEach((e)=>{ - eValue = e.title - if(eValue.includes(input.value)){ + let eValue = e.title.toLowerCase() + let inputValue = input.value.toLowerCase() + if(eValue.includes(inputValue)){ console.log(eValue) + + let card1 = ` +
+
+
+
+
${e.title}
+ ${e.dec} +
Read more + +
Writing by: ${e.writingBy} @${e.writingBy} +
+ +
+
+ +
+
+
+
+ +
+ + ` + mainRow.insertAdjacentHTML("beforeend",card1) + } + if(!eValue.includes(inputValue)){ + console.log("title not fount") } }) -}) \ No newline at end of file +}) +