zoukankan      html  css  js  c++  java
  • jquery判断一个标签是否包含另外一个标签

    jquery判断一个标签是否包含另外一个标签

    一、总结

    一句话总结:

    jquery的find方法配合length属性:if($("#video_md_9_1").find("#video_comment_tabs_part").length==0)

    二、jquery判断一个标签是否包含另外一个标签

      {{--当屏幕变小的时候:第一个col-md-9中的评论板块移动到第二个,先加第二个,再删第一个--}}
      <script>
          function fry_video_comment_part_move(){
              //console.log($(window).width());
              let video_comment_tabs_part=$('#video_comment_tabs_part');
              if($(window).width()>991){
                  //如果位置是对的,就不用变,位置不对才需要变
                  //如果#video_md_9_1没有#video_comment_tabs_part,就如下操作
                  if($("#video_md_9_1").find("#video_comment_tabs_part").length==0){
                      $('#video_md_9_1').append(video_comment_tabs_part);
                      $('#video_md_9_2').remove('#video_comment_tabs_part');
                  }
    
              } else{
                  if($("#video_md_9_2").find("#video_comment_tabs_part").length==0){
                      $('#video_md_9_2').append(video_comment_tabs_part);
                      $('#video_md_9_1').remove('#video_comment_tabs_part');
                  }
              }
          }
          $(function () {
              fry_video_comment_part_move();
              $(window).on('resize', function() {
                  //console.log("宽度改变了!");
                  //console.log($(window).width());
                  //layer_alert_success($(window).width());
                  fry_video_comment_part_move();
              }).resize();
              // window.onresize=function(){
              //
              // }
          });
      </script>

    三、用jquery判断某个元素下是否有标签?

    转自或参考:用jquery判断某个元素下是否有标签?
    https://blog.csdn.net/linhui03/article/details/78682339

    示例如下:

    <script>

    $(function(){

    if($(".top-4").find("a").length==0){

    $(".top-5").css("height","0px")

    }

    })

    </script>

     
  • 相关阅读:
    POJ 2486 Apple Tree(树形DP)
    HDOJ 4276 鬼吹灯 (树形DP)
    POJ 2923 Relocation(状态压缩DP)
    Vue,事件的修饰符
    Vye,v-if 和 v-show 显示隐藏的使用
    Vue,for循环的key值绑定
    Vue,v-for循环遍历方式
    Vue-class样式,style样式
    Vue,v-model双向事件绑定 及简易计算器练习
    uni-app 生命周期(下拉已解决)
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/11927134.html
Copyright © 2011-2022 走看看