jQuery Selectors: Select element with specific class and 'title' attribute
Very close:
$(".statuslight[title='" + currentStatus + "']");
Supposing your currentStatus
is an array, you could get all statuslight
elements with a title that contains any of the currentStatus
values with:
$(".statuslight[title='" + currentStatus[0] + "'], .statuslight[title='" + currentStatus[1] + "'], .statuslight[title='" + currentStatus[2] + "']");
Alternatively, if your title has multiple statuses (title="status1 status2 status3"
), and currentStatus
is only one item you would use this selector:
$(".statuslight[title~='" + currentStatus + "']");