javascript - Show/hide multiple Divs with checkbox without using ID's only class names -
Hello, I need help to show "show / hide div" below and when you want any one of the checkboxes Click on the section I am planning to make several sections and the number is unknown, so it will not be possible to use the id. So I was searching for a normal method if one area is clicked on "show / hide" a checkbox Appears in that area I know that you can get it by typing individual code and assigning an ID to each section, but is it a way to do this Is it that I am constantly looking at avoiding updating code?
and lieutenant ;! - Section 1 - & gt; Section 1 & lieutenant; Div class = "showHideDiv" & gt; Show / this div / lt; / Div & gt; & Lt; Div class = "custom-input" & gt; & Lt; Div class = "checkbox" & gt; & Lt; Input class = "" id = "" name = "" type = "checkbox" & gt; & Lt; Label class = "" = "" & gt; E-mail & lt; / Label & gt; & Lt; Input class = "" id = "" name = "" type = "checkbox" & gt; & Lt; Label class = "" = "" & gt; Print & lt; / Label & gt; & Lt; / Div & gt; & Lt; / Div & gt; Section 2 & lt ;! - Section 2 - & gt; & Lt; Div class = "showHideDiv" & gt; Show / Wrap this div & lt; / Div & gt; & Lt; Div class = "custom-input" & gt; & Lt; Div class = "checkbox" & gt; & Lt; Input class = "" id = "" name = "" type = "checkbox" & gt; & Lt; Label class = "" = "" & gt; E-mail & lt; / Label & gt; & Lt; Input class = "" id = "" name = "" type = "checkbox" & gt; & Lt; Label class = "" = "" & gt; Print & lt; / Label & gt; & Lt; / Div & gt; & Lt; / Div & gt; Section 3 & lt ;! - Section 3 - & gt; & Lt; Div class = "showHideDiv" & gt; Show / Wrap this div & lt; / Div & gt; & Lt; Div class = "custom-input" & gt; & Lt; Div class = "checkbox" & gt; & Lt; Input class = "" id = "" name = "" type = "checkbox" & gt; & Lt; Label class = "" = "" & gt; E-mail & lt; / Label & gt; & Lt; Input class = "" id = "" name = "" type = "checkbox" & gt; & Lt; Label class = "" = "" & gt; Print & lt; / Label & gt; & Lt; / Div & gt; & Lt; / Div & gt; Section 4 & lt ;! - Section 4 - & gt; & Lt; Div class = "showHideDiv" & gt; Show / Wrap this div & lt; / Div & gt; & Lt; Div class = "custom-input" & gt; & Lt; Div class = "checkbox" & gt; & Lt; Input class = "" id = "" name = "" type = "checkbox" & gt; & Lt; Label class = "" = "" & gt; E-mail & lt; / Label & gt; & Lt; Input class = "" id = "" name = "" type = "checkbox" & gt; & Lt; Label class = "" = "" & gt; Print & lt; / Label & gt; & Lt; / Div & gt; & Lt; / Div & gt;
Once you have set an invalid HTML (you have a closing and Lieutenant
$ (this) .closest (
'.custom-input') prev ('. ShowHideDiv') // where $ (this) checkbox is & quot; div class = "custom-input" & gt;
); / div & gt;
For example (based on comments) that are & Lt; Div & gt;
If none of the checkboxes are checked, and & lt; Div & gt;
, one or both of the check boxes are checked
Comments
Post a Comment