For the following HTML:
<p id="circleNouns">Now is the time for all good men to come to the aid of their country.</p>
First, leave each word of text in the <span> tags using jQuery:
var $cn = $('#circleNouns'), cnText = $cn.text(); cnText = cnText.replace(/\s/g, '</span> <span>'); $cn.html('<span>' + cnText + '</span>');
Then, if we draw a class to draw a circle as a border:
.selected { border:1px solid red; border-radius:30px; -webkit-border-radius:30px; -moz-border-radius:30px; }
We can simply add the following click event:
$cn.find('span').click(function(e) { $(this).toggleClass('selected'); });
Then, however, the page is submitted, you can check $cn.find('.selected') each .html() for its list of nouns to make sure the answers are correct.
Here a working example β
mVChr source share