I need to apply this script to work the same way for two other divs: This works well, but how can I make it do the same thing for two other elements without rewriting the entire thing for each?
$(".survey_option li > a").each().live('click', function (event) {
// First disable the normal link click
event.preventDefault();
// Remove all list and links active class.
$('.so_1 .active').toggleClass("active");
// Grab the link clicks ID
var id = this.id;
// The id will now be something like "link1"
// Now we need to replace link with option (this is the ID's of the checkbox)
var newselect = id.replace('partc', 'optionc');
// Make newselect the option selected.
$('#'+newselect).attr('checked', true);
// Now add active state to the link and list item
$(this).addClass("active").parent().addClass("active");
return false;
});