清除div

时间:2015-08-22 10:34:17

标签: javascript

此弹出类别的高度为0.按下按钮时,我将高度增加100%。里面有pop-up-wrap-category div,用于存储我的数据。 还有用于用户控件的div(关闭弹出窗口)。

<div class="pop-up-category">
  <div class="pop-up-wrap-category">
    <p>clear just this content</p>
//this this should be still visible(populated)
    <div class="user-controls">
      <span class="close-popup btn btn-danger">Close</span>
    </div>
  </div>
</div>

js:

 $(document).on("click", ".close-popup", function () {
       // console.log("sdasd");
        $('.pop-up-wrap-category').empty();
    });

如何从pop-up-wrap-category中清除内容,但用户控件仍然可见?

1 个答案:

答案 0 :(得分:1)

找到p并清除p

$(document).on("click", ".close-popup", function () {
     // console.log("sdasd");
     $('.pop-up-wrap-category > p').empty();  //use .remove() if you want to get the p tag deleted from DOM
});