appendTo时不要使用jquery函数吗?

时间:2017-05-16 12:16:42

标签: javascript jquery html css

我有两个div,如果我调整页面的大小小于768px,那么我的.tFFiltre div正在移动.tFPopup div ..所以到目前为止一切都还好但移动后我不会我想让工作成为我的js功能

例如,如果你点击change background复选框按钮,你会看到背景颜色正在变暗但是如果我在另一个div中移动我的div而不是不改变背景颜色..所以我的意思是我不想制作工作js功能

$(document).ready(function(){
 $('#checkbox').change(function() {
  if ($(this).is(':checked')) {
   $("body").css("background","red");
  } else {
    $("body").css("background","white");
  }
});
  
});

$(window).resize(function() {
    if ($(window).width() < 768) {
        $('.tFFiltre').appendTo('.tFPopup');
    } else {
        $('.tFFiltre').appendTo('.backFilter');
    }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="tFFiltre backFilter">
  <h1>Hi this is my filter title</h1>
  <p>and this is my article for filter</p>
  <span>and I have some elements</span>
  <button>html button</button>
  <pre>code bla bla </pre>
  <xmp>
    <html>
      <head></head>
      <body></body>
    </html>
  </xmp>
  
  <input type="checkbox" id="checkbox"> <label for="checkbox">change background
</div>


<div class="tFPopup">
  <h3>.tFFiltre div will be moved here </h3>
</div>

1 个答案:

答案 0 :(得分:1)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="tFFiltre backFilter">
  <h1>Hi this is my filter title</h1>
  <p>and this is my article for filter</p>
  <span>and I have some elements</span>
  <button>html button</button>
  <pre>code bla bla </pre>
  <xmp>
    <html>
      <head></head>
      <body></body>
    </html>
  </xmp>
  
  <input type="checkbox" id="checkbox"> <label for="checkbox">change background
</div>


<div class="tFPopup">
  <h3>.tFFiltre div will be moved here </h3>
</div>
extern "C"
{
    
    void _AddNotification(const char* title,
                          const char* body,
                          const char* cancelLbl,
                          const char* firstLbl,
                          const char* secondLbl,
                          const char* tables[])
    {
  
        
      
     }
}

请检查代码
我已获得整个元素,然后追加所需位置

谢谢