I have a div with id ="propertiesDiv". It has certain input elements. All of them are text fields. Some of them have names like propertyName1, propertyName2 etc. I need to get all such inputs with names starting from "propertyName".
Below is code I have written so far but it gets me all inputs within that div.
$('#propertiesDiv').find('input').each(function(index, element){
var name = element.name;
});
Please help
You're loking for jQuery's starts with
selector (docs)
$('#propertiesDiv').find("input[name^='propertyName']")
Live example: http://jsfiddle.net/zZYtj/
You can do like this
$( 'input[name^="propertyName"]' , $('#propertiesDiv'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With