Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Awesome To-Do List HTML,CSS & JavaScript</title>
  <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <link rel="stylesheet" href="style.css"> 
</head>
<body>
	<div class="container">
		<div class="addTask">
			<input type="text" placeholder="Add a Task">
			<button>Add</button>
		</div>

		<ol class="notCompleted">
			<h3>Not Completed</h3>
		</ol>

		<ol class="Completed">
			<h3>Completed</h3>
		</ol>
	</div>

	<script>
		const input = document.querySelector('input');z
		const btn = document.querySelector('.addTask > button');

		btn.addEventListener('click', addList);
		input.addEventListener('keyup', (e)=>{
			(e.keyCode === 13 ? addList(e) : null);
		})

		function addList(e){
			const notCompleted = document.querySelector('.notCompleted');
			const Completed = document.querySelector('.Completed');

			const newLi = document.createElement('li');
			const checkBtn = document.createElement('button');
			const delBtn = document.createElement('button');

			checkBtn.innerHTML = '';
			delBtn.innerHTML = '^__i class="fa fa-trash">';


			if(input.value !==''){
				newLi.textContent = input.value;
				input.value = '';
				notCompleted.appendChild(newLi);
				newLi.appendChild(checkBtn);
				newLi.appendChild(delBtn);
			}

			checkBtn.addEventListener('click', function(){
				const parent = this.parentNode;
				parent.remove();
				Completed.appendChild(parent);
				checkBtn.style.display = 'none';
			});

			delBtn.addEventListener('click', function(){
				const parent = this.parentNode;
				parent.remove();
			});
		}

	</script>
</body>
</html>


What I have tried:

 const notCompleted =$('ntdone');
const Completed = $('.completed');   
const newLi = $('<li></li>');
const checkBtn = $('<button></button');
const delBtn = $('<button></button');

checkBtn.innerHTML = '';
			delBtn.innerHTML = '^__i class="fa fa-trash">';


			if(input.value !==''){
				newLi.text = input.value;
				input.value = '';
				notCompleted.appendTo(newLi);
				newLi.appendTo(checkBtn);
				newLi.appendTo(delBtn);
			}

			checkBtn.addEventListener('click', function(){
				const parent = this.parentNode;
				parent.remove();
				Completed.appendTo(parent);
				checkBtn.style.display = 'none';
			});

			delBtn.addEventListener('click', function(){
				const parent = this.parentNode;
				parent.remove();
			});
		}
Posted
Updated 9-Apr-22 6:08am

1 solution

There is no "conversion" to jQuery. It's not a language. jQuery is a library of modules, written in javascript, designed to make writing common functionality in javascript simpler, smaller, and more supportable.

Is there something in jQuery that will do what your code is doing? What is your code supposed to be doing?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900