
Collapsed div open and close based in ID

1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jayraj ChhayaRank #304 · 8.2K reputationPosted Apr 9, 2024, 2:17 AM EDT
$(document).ready(function(){ $(".collapsed").click(function(){ var divId = $(this).attr('id'); $("#" + divId).slideToggle(); }); });you can utilize the
slideToggle()function to toggle the visibility of the targeted div when a specific event occurs.