Home > front end >  Want to use jquery to solve a problem, a great god have a look.
Want to use jquery to solve a problem, a great god have a look.

Time:10-04

Known to have five checkbox
The content about the following
Procedure 1 checkbox
Formalities 2 checkbox
Procedure of 3 checkbox
Procedure 4 checkbox
Procedures of 5 checkbox

Each selected a checkbox in the top of the page displays the contents of a checkbox
For example 1 and procedures selected 4 checkbox
Page 1 that is displayed above the procedures and formalities 4

Then uncheck procedure 1, and then select the procedure 5
Page reservation procedures before 4, additional procedure 5, delete procedures 1

How to implement it with jq
New small white, the great god help see


CodePudding user response:

Have eldest brother see ah I can't

CodePudding user response:

Brother have any great god took me fly

CodePudding user response:

Writing is more rough, can try

 
& lt; Div id="final" & gt; & lt;/div>
& lt; Div>
& lt; Input type="checkbox" name="ck" value="https://bbs.csdn.net/topics/1" id="ck1 & gt;"
& lt; The label for="ck1 & gt;" Procedure 1 & lt;/label>
& lt;/div>
& lt; Div>
& lt; Input type="checkbox" name="ck" value="https://bbs.csdn.net/topics/2" id="ck2 & gt;"
& lt; The label for="ck2" & gt; Procedures for 2 & lt;/label>
& lt;/div>
& lt; Div>
& lt; Input type="checkbox" name="ck" value="https://bbs.csdn.net/topics/3" id="ck3" & gt;
& lt; The label for="ck3" & gt; Procedure of 3 & lt;/label>
& lt;/div>
& lt; Div>
& lt; Input type="checkbox" name="ck" value="https://bbs.csdn.net/topics/4" id="ck4 & gt;"
& lt; The label for="ck4" & gt; Procedures for 4 & lt;/label>
& lt;/div>
& lt; Div>
& lt; Input type="checkbox" name="ck" value="https://bbs.csdn.net/topics/5" id="ck5 & gt;"
& lt; The label for="ck5" & gt; Procedures of 5 & lt;/label>
& lt;/div>

 
& lt; Script>
$(function () {
$(" input [name='ck'] "). Click (function () {
Var t=$(this);
Var c=$(" # final "). The text ();
Var n=t.s iblings (' label '). The text ();
Var q=t.p rop (" checked ")==true? C.s. plit (c + n) : ((n.) the join (" "));
$(" # final "). The text (q);
});
});
& lt;/script>

CodePudding user response:

 
& lt; Div id="text" & gt; & lt;/div>
Procedure 1 & lt; Input type="checkbox" value="1" https://bbs.csdn.net/topics/formalities/& gt; & lt; Br>
Procedures for 2 & lt; Input type="checkbox" value="https://bbs.csdn.net/topics/formalities 2"/& gt; & lt; Br>
Procedure of 3 & lt; Input type="checkbox" value="https://bbs.csdn.net/topics/procedure 3"/& gt; & lt; Br>
Procedures for 4 & lt; Input type="checkbox" value="https://bbs.csdn.net/topics/procedure 4"/& gt; & lt; Br>
Procedures of 5 & lt; Input type="checkbox" value="https://bbs.csdn.net/topics/procedures 5"/& gt; & lt; Br>
& lt; The script type="text/javascript" & gt;
$(" check "). The change (function (event) {
$(" # text "). The text ($(". Check: checked "). The map (the function () {
Return the $(this). Val ();
}). The get (). The join () ", ");
});
& lt;/script>
  • Related