Vatan Soni Vatan Soni - 2 months ago 10
jQuery Question

How to filter elements based on substring of multiple name using jquery, I tried below but not worked:

I tried below thing but not worked:

$( "input[id][name*='Address.Line1'][name*='Address.Line2'][name*='Address.City'][name*='Address.StatesList'][name*='Address.CountryList'][name*='Address.PostalCode']")


I need all elements based on "OR" condition.

Please help.

Answer

Use comma separated multiple selectors for that.

$("input[id][name*='Address.Line1'],input[id][name*='Address.Line2'],input[id][name*='Address.City'],input[id][name*='Address.StatesList'],input[id][name*='Address.CountryList'],input[id][name*='Address.PostalCode']")

Use filter() method to make it more readable.

$( "input[id]").filter("[name*='Address.Line1'],[name*='Address.Line2'],[name*='Address.City'],[name*='Address.StatesList'],[name*='Address.CountryList'],[name*='Address.PostalCode']");
Comments