[jQuery] select change() event
<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Arial; font-size: 12pt; color: #000000'>right now I have the following, the current code works fine until there are multiple .parent-jqueryColor objects.
Basically what I need to solve this is a way to get the selected option of the $(this).
$(".parent-jqueryColor").change(
function() {
var opt = ($".parent-jqueryColor option:selected");
id = "#" + $part + "-colorSwatch";
if ( typeof(opt.attr("hex")) != "undefined" ) {
if ( $(this).attr("hex") != "" ) {
$(id).css("background-color", "#" + opt.attr("hex"));
} else {
$(id).css("background-image","url(images/swatches/" + opt.attr("image") + ")" );
}
} else {
$(id).css( "background-color", "" );
$(id).css( "background-image","");
}
}
);
</div></body></html>