Refactor: Javascript block
- by Shpigford
Need some help refactoring this code:
$("span[rel=color_content]").ColorPicker({
onChange: function (hsb, hex, rg) {
$("span[rel=color_content]").css('background-color', '#' + hex);
}
});
$("span[rel=color_link]").ColorPicker({
onChange: function (hsb, hex, rg) {
$("span[rel=color_link]").css('background-color', '#' + hex);
}
});
$("span[rel=color_selected]").ColorPicker({
onChange: function (hsb, hex, rg) {
$("span[rel=color_selected]").css('background-color', '#' + hex);
}
});
$("span[rel=color_page]").ColorPicker({
onChange: function (hsb, hex, rg) {
$("span[rel=color_page]").css('background-color', '#' + hex);
}
});
$("span[rel=color_player]").ColorPicker({
onChange: function (hsb, hex, rg) {
$("span[rel=color_player]").css('background-color', '#' + hex);
}
});
The only thing changing between each is the contents of the rel attribute.