How to hide/show items on a webpage using jquery upon a click event on a checkbox (suppose there are multiple checkboxes each with its related items)?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Some javascript code in your page waits for the page to load and then registers for the click event on a checkbox and when the value of the checkbox is changed, the code looks at the current value and then hides/shows other items on the web page.
In some instances, it might even make an ajax call to the server to obtain new content and then insert that content into the page.
In jQuery, you could do this:
This would work for a checkbox with
id="showRelatedItemsand a set of related items withclass="relatedItems".Working demo: http://jsfiddle.net/jfriend00/egYJj/