Consider something like this:
CSS
<style type="text/css">
span.answer{
text-decoration: underline;
border: none;
padding: 2px;
cursor: pointer;
}
span.answer_selected{
border: 1px solid red;
-webkit-border-top-right-radius: 10px; -webkit-border-top-left-radius: 10px;
-moz-border-radius-topright: 10px; -moz-border-radius-topleft: 10px;
-webkit-border-bottom-right-radius: 10px; -webkit-border-bottom-left-radius: 10px;
-moz-border-radius-bottomright: 10px; -moz-border-radius-bottomleft: 10px;
}
</style>
Javascript
<script type="text/javascript">
$(document).ready(function(){
$("div.question > span.answer").click(function() {
$(this).siblings(".answer").removeClass("answer_selected");
$(this).addClass("answer_selected");
}
);
});
</script>
HTML
<div class="question" id="q_1">question 1<br/>
<span class="answer" id="a_1">answer one</span> /
<span class="answer" id="a_2">answer two</span>
</div>
<div class="question" id="q_2">question 2<br/>
<span class="answer" id="a_1">answer one</span> /
<span class="answer" id="a_2">answer two</span>
</div>
This idea should be pretty easy to adapt to a jQuery plugin. You can change the HTML tags to reflect a form or whatever else you had in mind.
You can let the answers be 'uncircled' of course, if you want:
<script type="text/javascript">
$(document).ready(function(){
$("div.question > span.answer").click( function() {
if ($(this).hasClass("answer_selected")){
$(this).removeClass("answer_selected");
} else {
$(this).siblings(".answer").removeClass("answer_selected");
$(this).addClass("answer_selected");
}
});
});
</script>
- caveat: css3 is not final and neither internet explorer nor opera will render your pretty rounded borders. The answered will be... erm, "squared."