Home > Article > Web Front-end > How to Select Inputs with Square Brackets in Their Name Attribute Using jQuery?
You may encounter a scenario where you need to select HTML input elements having square brackets ([]) within their name attribute. However, using conventional selectors like $('input[inputName[]=someValue]') or $('input[inputName[]=someValue]') might not yield the desired results.
According to the jQuery documentation, you can successfully select such inputs using a modified syntax as follows:
$('input[inputName\[\]=someValue]')
Alternatively, a more comprehensive selector would be:
$('input[name="inputName[]"][value="someValue"]')
With this, you can now target and manipulate input elements containing square brackets in their name attributes efficiently.
The above is the detailed content of How to Select Inputs with Square Brackets in Their Name Attribute Using jQuery?. For more information, please follow other related articles on the PHP Chinese website!