Mastering jQuery HTML & CSS helps you write clean and reliable jQuery code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
jQuery HTML & CSS Code Example
jQuery
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<style> .done { text-decoration: line-through; color: #94A3B8; } </style>
<input id="task" placeholder="New task"> <button id="add">Add</button>
<ul id="list"><li>Learn jQuery</li></ul>
<p><small>Click a task to mark it done.</small></p>
<script>
$("#add").click(function () {
const text = $("#task").val().trim();
if (!text) return;
$("#list").append($("<li>").text(text));
$("#task").val("");
});
$("#list").on("click", "li", function () {
$(this).toggleClass("done");
});
</script>
Free sign-in required · Google login available
jQuery HTML & CSS Practice Exercises
Check what you learned in “jQuery HTML & CSS”.
/ 3 solved
Fill in the blank
Read the value of an input.
const name = $("#name").();
✓ Correct!Not quite. Try again.
Multiple choice
Which method inserts content at the end of the selected element?
✓ Correct!Not quite. Try again.
Code challenge
Append a new <li> with the text "Three" to #list.
Write the code in the live editor. Your answer is checked automatically.