Skip to content

OmolloRovy/Dom-Manipulation-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shopping list Application

This is a simple web application that allows users to create and manage a shopping list. Users can add items to the list and remove them when they're done.

Features

  • Add Items: Type an item into the input field and click the "Add Item" button (or press Enter) to add it to the list.
  • Remove Items: Click the "x" button next to an item to remove it from the list.
  • Clean and Efficient: Uses event delegation for efficient removal of list items.
  • User-Friendly: Simple and intuitive interface.
  • Enter Key Support: Pressing Enter in the input field adds the item.

Technologies Used

  • HTML
  • CSS
  • JavaScript

How to Use

  1. Clone the Repository (Optional): If you want to run this locally, you can clone this repository: git clone [repository URL]
  2. Open the HTML File: Open the index.html file in your web browser.
  3. Add Items: Type the name of an item in the input field and click the "Add Item" button or press Enter.
  4. Remove Items: Click the "x" button next to the item you want to remove.

Project Structure

  • index.html: The main HTML file containing the structure and content of the shopping list app.
  • style (within the <style> tags in index.html): Contains the CSS styles for the app's appearance.
  • script (within the <script> tags in index.html): Contains the JavaScript code for the app's functionality.

Explanation of Key Concepts

  • Event Delegation: The JavaScript code uses event delegation to handle the removal of list items. This means that instead of adding an event listener to each individual "x" button, a single event listener is attached to the parent <ul> element. When a click occurs, the event listener checks if the clicked element has the class "remove-button". If it does, the corresponding list item is removed. This is a more efficient approach, especially when dealing with a large number of items or dynamically added items.

  • textContent: The code uses textContent to set the text of the list items. textContent is generally preferred over innerHTML because it is safer (prevents potential cross-site scripting (XSS) vulnerabilities) and performs better.

  • trim(): The trim() method is used to remove any leading or trailing whitespace from the input value before adding it to the list. This prevents users from accidentally adding empty list items.

Future Improvements

  • Local Storage: Implement local storage to save the shopping list so it persists even after the browser is closed.
  • More Styling: Improve the styling of the app to make it more visually appealing.
  • Edit Functionality: Add the ability to edit existing list items.
  • Quantity Input: Allow users to specify the quantity of each item.
  • Checkboxes/Mark as Purchased: Add checkboxes or a way to mark items as purchased.

Contributing

Contributions are welcome! If you have any suggestions or bug fixes, please open an issue or submit a pull request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors