Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Buzzfeed style quizz - Deactivate part of page on user click

Hi,

I'm trying to create a quizz in the style of Buzzfeed and I was wondering if there is a way to deactivate part of the page when the user clicks on an answer so that users can no longer click on alternative options of the same question and distort the final score of the test.

I created a codepen here http://codepen.io/kkoutoup/pen/ByGEoQ

Any ideas?

Thanks

1 Answer

As a quick suggestion, perhaps when a checkbox is checked fire off a function that loops over all of the checkboxes related that question and add the disabled = true to all those with an unchecked status. I know something like this can be done in plain old javascript but unsure of the syntax for jquery.

Good luck

David Millarvie Thanks for this. I was thinking of that but since I'm not using input elements I was wondering if there was a way to do it without changing my code.Another alternative that was suggested was using jquery's .off() method to deactivate any clicks for the specific element.

$(this).parent().find('li').off("click");

which will locate the parent element and disable clicks on it.