jQuery: Attribute Starts With Selector

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

For example in following example, I am trying to get values of all Select those ids start with “dd_extra_”.

HTML

jQuery

$.each($("select[id^='dd_extra_']"), function(key, element) {
    console.log($(element).val()); // printing the value of element    console.log($(element).attr('id')); // printing the actual id of the element
});

Official documentation link, click here

Register Or Login to leave a comment.