I have an array of options:
var options = ["foo_A", "foo_B", "foo_C", "foo_D"];
…and when a user clicks on one of the following elements…
<div id="bar_A"> </div>
<div id="bar_B"> </div>
<div id="bar_C"> </div>
<div id="bar_D"> </div>
…it sets the following variable:
var currentBar = $(this).attr('id');
…and then I’d like to search through the options array and find the item whose suffix matches that of currentBar, something like this:
$.each(options, function(i,v){
if (v's suffix matches the currentBar's suffix){
//function to do something
}
1 Answer