Reputation: 3
I am not sure how to use (OR) operator with JQUERY.
$(document).ready(function(){
$('#selection1')||('#selection2')||('#selection3').click(function(e) {
$('#thecheckbox').removeAttr('disabled');
});
});
Is it possible with .click functionto use (||) operator, if possible HOW? Apearently not the way I did.
Upvotes: 0
Views: 126
Reputation: 12040
I am not completely sure this is what you want to do, anyway if it is not the multiple element selection already written by Andrei then maybe you're looking for this:
$(document).ready(function(){
var s1 = $('#selection1'),
s2 = $('#selection2'),
s3 = $('#selection3'),
selection = s1.length !== 0 ? s1 : s2.length !== 0 ? s2 : s3.length !== 0 ? s3 : null;
selection.click(function(e) {
$('#thecheckbox').removeAttr('disabled');
});
});
Upvotes: 0
Reputation: 1206
if i understand your question correctly, you can do this instead,
$(document).ready(function(){
$('#selection1, #selection2, #selection3').click(function(e) {
$('#thecheckbox').removeAttr('disabled');
});
});
Upvotes: 1
Reputation: 56726
$(document).ready(function(){
$('#selection1, #selection2, #selection3').click(function(e) {
$('#thecheckbox').removeAttr('disabled');
});
});
jQuery supports comma-separated list of selectors, which in this case means that click handler will be applied to all elements having one of the IDs. Here is the reference.
Upvotes: 2