Projects

Create Messenger Pop Up ChatBox Type Writer ChatGpt Basic Copy Text Using Tolltip Digital Clock CountDown Timer Create StopWatch FB login from Tab Button Accordion Auto Image Gallery DropDown Menu Modal Box Modal Image Box Scroll Indicator To Do List Autocomplete Remember Search History Toggle Switch Calender Layout Dynamic Calender Alarm Set Password Validation Password Generator Age Calculator Multi Step Form Weather API

Autocomplete

Note: If you are a beginner, this is something you need to know. Scroll the below section or Click here
  • HTML DOM(querySelector,querySelectorAll etc)
  • appendChild in JS
  • addEventListener in JS

Basic Autocomplete

HTML




JavaScript


addcross();

function addcross(){
    // console.log(cross.innerHTML);
    
    let lists=document.querySelectorAll(".works ul li");
    //console.log(lists);
    for(let i=0;i< lists.length;i++){
        let cross=document.createElement("span");
        let txt=document.createTextNode("\u00D7");
        cross.appendChild(txt);
        lists[i].appendChild(cross);
        
        
        
    }

    //console.log(lists);
}


function addList(){

    if(document.getElementById("add").value==""){
        return false;
    }
    let li=document.createElement("LI");
    li.innerHTML=document.getElementById("add").value;
    document.querySelector(".works ul").appendChild(li);
    document.getElementById("add").value="";
    //console.log(li);


    //addd cross to the last li Element
    let last=document.querySelectorAll(".works ul li");
    let cross=document.createElement("span");
    let txt=document.createTextNode("\u00D7");
    cross.appendChild(txt);
    last[last.length-1].appendChild(cross);

}


let list=document.querySelector(".works ul");

list.addEventListener( "click", event=>{
    //console.log(event.target.className);
    if(event.target.tagName=="LI"){
        event.target.classList.toggle("checked");
        //console.log(event.classList);
    }

    //console.log(event.target.tagName);
    if(event.target.tagName=="SPAN"){
        event.target.parentElement.style.display='none';
        //console.log(event.target.parentElement);

    }

})

CSS




new Date()

  • Returns a Date object with the current date and time based on the system's clock.
  • This create a date object represent the current date and time.

toString()

  • The toString() method converts any data type into a string. Syntax: varname.toString(),

padStart()

  • It is used to JS to pad the current string with another string untill the resulting string reaches the given length.
    Example: str.padStart(len,char or string);

setInterval()

  • This method in JS repeatedly calls a function or executes a code with a fixed time delay between each call.

setTimeout()

  • This method is used to execute a function or code snippet after a specified delay in milliseconds.

date.get....()

  • getDate(): Returns the day of the month(1-31)
  • getMonth(): Returns the month(0-11)
  • getFullYear(): Returns the year(4 digit year)
  • getDay(): Returns the day of the week(0-6)
  • getHours(): Returns the hours(0-23)
  • getMinutes(): Returns the minites(0-59)
  • getSeconds(): Returns the seconds(0-59)
  • getMilliseconds(): Returns the milliseconds(0-999)
  • getTime(): Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC