In a click handler, you can use the this
keyword to access the thing that was clicked on.
Then you can get attributes from the thing that was clicked without having to select it again.
Instead of $("#someid").attr("data-color")
, you can use $(this).attr("data-color")