1

Hi all i am working on jquery here i have a html code like this

<div>
    <span class="span1">
      <label class="checkbox" />
          <input type="checkbox" class="regular-checkbox" id="Header" />
          <label for="Header"></label>
      </label>
    </span> 
    <span class="span1">Images</span> 
    <span class="span1">SKU</span>
    <span class="span2">Name</span> 
    <span class="span1">Price</span>                             
</div>

<div id="separate"></div>
      <input type="button" id="button" />

i had tried like this it dosen't works

<script type="text/javascript">
    $(document).ready(function(){
    $(#button).click(function(){
   $(function () {

      $("input:checkbox").toggle(function () {
         $("#Header").appendTo("#separate");
      },function () {
         $("#separate").appendTo($(this));
      });
      });

   });
</script>

i have this DIV in which i have a checkbox from here i have an image, price and name (cell phone). This is my code and i have a 'href' icon when i select the checkbox, and i submited the image and price and name should move to another DIV how can I do this and when i deselect the checkbox? It should toggle. Could u please help me on how to fix this, thanks in advance.

4

2 に答える 2

2

これは私がそれを行う方法です。http://jsbin.com/umivoc/1/

JavaScript:

$(function () {
  // Check if user clicks on the checkbox
  $("#Header").click(function() {

    if($('#Header').is(':checked')){

      // If the checkbox becomes checked, 
      // move the contents to our new div (div2)
      $("#div1").contents().appendTo("#div2");
    } else {

      // Otherwise we can assume it is being unchecked, 
      // so move everything back to it's original div (div1)
      $("#div2").contents().appendTo("#div1");
    }
  });
});


HTML マークアップ:
マークアップをかなりクリーンアップしました。ラベル タグが開いていました。簡単にするために、移動する要素を独自のラッパー div 内に配置する必要があります。

<span class="span1">
   <label for="Header"></label>
   <input type="checkbox" class="regular-checkbox" id="Header" />
</span> 
<div id="div1">
   <span class="span1">Images</span> 
   <span class="span1">SKU</span>
   <span class="span2">Name</span> 
   <span class="span1">Price</span>                             
</div>
<div id="div2"></div>
于 2012-11-20T07:59:33.937 に答える
0

何が必要かはあまり明確ではありませんが、解決策につながる可能性があります。

<input type="checkbox" class="regular-checkbox" id="Header" />
<br/>
Pos:1
<div id="oryginal">
    <span class="span1">Images</span> 
    <span class="span1">SKU</span>
    <span class="span2">Name</span> 
    <span class="span1">Price</span>
</div>                           
<br/>
Pos:2
<div id="separate"></div>​

$("input:checkbox").toggle(
   function () {
         $("#oryginal span").appendTo("#separate");
      },function () {
         $("#separate span").appendTo("#oryginal");
      });
于 2012-11-20T08:04:57.950 に答える