[jQuery] switching color function
I have several lines of code that are almost identical like this:
$(function(){
$('p.productColorWhite').click(function(){
switchColor(this);
});
$('p.productColorTranslucent').click(function(){
switchColor(this);
});
$('p.productColorBlack').click(function(){
switchColor(this);
});
});
How can I write this in a way that is less repetitive or uses better
practice?
I'd like to do something like this:
$(function(){
$('p.productColor*').click(function(){
switchColor(this);
});
});
But, I know that is not correct syntax...