-1
$(document).on('click', '#cart', function() {
}

from the documentation, the parameters of the on() function are event, selector, and handler. 'cart' is an ID on an element in the document. If I remove the # before the cart, the code breaks.

Nazrin H.
  • 3
  • 2
  • 1
    `#cart` is an ID selector. The `#` prefix will target anything that has an ID matching whatever string follows it. – BenM May 30 '22 at 18:32
  • You would have googled it. To select an element we use selector. The selector can be an id, class, name of the tag or relatively positioned to another element. The # denotes an ID selector where #cart is an element with id="cart" – Marikkani Chelladurai May 30 '22 at 18:35

0 Answers0