How to find inputs with an attribute name starting with specific letter or text using jQuery?
In this article, we will learn to find input with an attribute name starting with a specific letter or text. This task is implemented using attributeStartWith selector.
attributeStartWith selector: This selector selects elements that have the specified attribute with a value beginning exactly with a given string. It has two arguments i.e attribute and value.
jQuery( "[attribute^='value']" )
- attribute: Name of the attribute.
- value: The value of an attribute (identifier or quoted sting).
The attributeStartWith selector can be useful for identifying elements in pages produced by server-side frameworks that produce HTML with systematic element ids.
Example: Finds all inputs with an attribute name that starts with ‘GFG’ and puts the text in them.