Skip to content

Instantly share code, notes, and snippets.

"number of persons" form field has dynamic created IDs. The field QTY input type="number"
I've added buttons and some jquery, however, because I have multiple "person_types" fields, the plus / minus onclick is affecting all the fields
How to target the individual fields using something like a foreach - but within the jquery?
current code in functions file
// get IDs from dynamic person_type field
$("input[id^='wc_bookings_field_persons_']").each(function() {
var id = parseInt(this.id.replace("wc_bookings_field_persons_", ""), 10);