I have elements in my page with ids like "abc_1_2_3_xyz" .How do I select element in Jquery which starts with "abc" and ends with "xyz"?
$('div[id^="abc"], div[id$="xyz"]');
I have elements in my page with ids like "abc_1_2_3_xyz" .How do I select element in Jquery which starts with "abc" and ends with "xyz"?
$('div[id^="abc"], div[id$="xyz"]');
Use filter:
$('div')
.filter(function() {
return this.id.match(/^abc+xyz$/);
})
.html("Matched!")
;