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>

     
  • 相关阅读:
    python读写excel等数据文件方法
    学习记录2
    NLP、ML/DL等基础概念
    修改代码的艺术-读后感
    Python读取文本文件数、excel文件数据
    学习记录1
    数据分析平台
    Pycharm搜索关键词的快捷键
    程序员的自我修养阅读笔记三
    第十周学习
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/11927134.html
Copyright © 2011-2022 走看看