-5
$('[id^="save_"]').click(function () {});

How is the element being selected using id here?

Makyen
  • 31,849
  • 12
  • 86
  • 121

2 Answers2

0

Selects every element whose id attribute value begins with "save_"

Marco Principio
  • 475
  • 3
  • 9
0

As quoted from the jQuery website:

Selects elements that have the specified attribute with a value beginning exactly with a given string.

https://api.jquery.com/attribute-starts-with-selector/

So if you have in your DOM two elements which are #save_address and #save_cart to select both of them by the same prefix save_ you will use $("[id^='save_']")

shemaya
  • 156
  • 2
  • 13