rubies rubies - 10 days ago 7
Javascript Question

jQuery conditional based on multiple selection

I have two IDs and I would like to create a condition based on my query.

$("#foo", "#bar").foo.bar({
baz: function() {
if(selector == "#foo") {
console.log("foo");
} else {
console.log("bar");
}
}
});

Answer

You can go so well?

var x = $('.foo, .bar');
if(x.hasClass('foo')){
  // True!
} else {
  // false!
}