Home > front end >  Questions about the jQuery mobile div, please everyone a great god to help me ~!
Questions about the jQuery mobile div, please everyone a great god to help me ~!

Time:09-17

: 1. The implementation of function to choose the storage containers (click on red div get id), then click on the [move] button to green the whole mobile div to red div inside, here can realize functions,
2. Question: but I want to move the green div move back again after box, here have a problem, point the move button no response, please to see where I went wrong thank you
The code is as follows:
 




<meta charset="UTF-8">
<meta name="viewport" content="width=device - width, initial - scale=1.0" & gt;
<script SRC="https://code.jquery.com/jquery-3.2.1.min.js" & gt; </script>
Removable div
<style>
# div1 {
Height: 300 px;
width: 200px;
background-color: red;
Margin: 5 px;
Float: left;
text-align: center;
}

# div2_0 {
Height: 150 px;
width: 150px;
Background - color: green.
margin-top: 10px;
Border: 1 px solid RGB (20, 20, 20);
}

# box {
Width: 950 px;
Height: 900 px;
Border: RGB (7, 7, 7) solid 1 px;
margin: 0 auto;
/* padding - left: 10 px; */
}

# left_list {
Width: 220 px;
Height: 800 px;
Background - color: chartreuse.
Margin: 10 px;
Float: left;
}

# center_list {
Width: 650 px;
Height: 800 px;
Background - color: burlywood;
Float: left;
Margin: 10 px;
}
</style>


<body>

Need to move the div2_0 & lt;/p>



Mobile storage containers div1 & lt;/p>





<script>
//click page elements for a click the id of the element
The $(document). Click (function (e) {
V_id="#" + e. arget. Id.
The console. The log (v_id);
});
//move the elements to the choice of internal div
The function moveHtml (obj) {
Var BTN="#" + $(obj). The parent (). The attr (" id ");
Var outHtml=$(BTN). Prop (" outerHTML ");
$(v_id). Append (outHtml);
$(BTN). Remove ();//remove the original HTML
}
</script>



CodePudding user response:

 
<script>
Var v_dom;
//click page elements for a click the id of the element
The $(document). Click (function (e) {
V_dom=e. arget;
The console. The log (v_dom. Id);
});
//move the elements to the choice of internal div
The function moveHtml (obj) {
Var BTN=$(obj). The parent ();
$(v_dom). Append (BTN);
}
</script>
  • Related