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

How is the element being selected using id here?

Makyen
  • 29,855
  • 12
  • 76
  • 115

2 Answers2

0

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

Marco Principio
  • 415
  • 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
  • 146
  • 2
  • 12