The Journey of #100DaysOfCode (wassim_taleb)

๐ƒ๐š๐ฒ ๐Ÿ•: ๐œ๐ฅ๐š๐ฌ๐ฌ๐‹๐ข๐ฌ๐ญ ๐ฏ๐ฌ. ๐š๐๐๐‚๐ฅ๐š๐ฌ๐ฌ ๐Ÿ๐ฎ๐ง๐œ๐ญ๐ข๐จ๐ง๐ฌ

classList and addClass are methods used to, ๐ฆ๐š๐ง๐ข๐ฉ๐ฎ๐ฅ๐š๐ญ๐ž ๐ญ๐ก๐ž ๐œ๐ฅ๐š๐ฌ๐ฌ๐ž๐ฌ ๐จ๐Ÿ ๐ƒ๐Ž๐Œ ๐ž๐ฅ๐ž๐ฆ๐ž๐ง๐ญ๐ฌ, but they serve different purposes:

โ†’ The purpose of classList is to provide a native and versatile way to ๐š๐๐, ๐ซ๐ž๐ฆ๐จ๐ฏ๐ž, ๐ญ๐จ๐ ๐ ๐ฅ๐ž, and ๐œ๐ก๐ž๐œ๐ค classes on DOM elements.

โ†’ The purpose of addClass is to ๐š๐๐ ๐œ๐ฅ๐š๐ฌ๐ฌ๐ž๐ฌ to elements using ๐ฃ๐๐ฎ๐ž๐ซ๐ฒ ๐ฅ๐ข๐›๐ซ๐š๐ซ๐ฒ. It requires jQuery and is less versatile, mainly used in projects already using jQuery.

2 Likes