Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何用php删除任何类的空div_Php - Fatal编程技术网

如何用php删除任何类的空div

如何用php删除任何类的空div,php,Php,如何用php删除任何类的空div。下面是代码。 使用jquery删除div请尝试以下代码 if($("div").empty()){ $(this).remove(); } 试试这个。。它检查每个元素是否有类。下拉列表并检查它是否为空 jQuery $('.dropdown').each(function(i, obj) { if( $(this).is(':empty') ) { $(this).remove(); } }); 使用jq

如何用php删除任何类的空div。下面是代码。


  • 使用jquery删除div请尝试以下代码

    if($("div").empty()){
        $(this).remove();
    }
    

    试试这个。。它检查每个元素是否有类。下拉列表并检查它是否为空

    jQuery

    $('.dropdown').each(function(i, obj) {
        if( $(this).is(':empty') ) { 
              $(this).remove();
        }
    });
    

    使用
    jquery
    进行查询

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
            $("div").each(function()
                {
                if($(this).empty())
                    $(this).remove()
                });
             })
    </script>       
    
    
    $(文档).ready(函数(){
    $(“div”)。每个(函数()
    {
    if($(this.empty())
    $(this.remove())
    });
    })
    
    您不能用PHP删除
    s。您可以使用JavaScript来实现这一点。请解释或发布您尝试的完整代码。。处理html元素是用客户端脚本完成的。我得到这个作为post参数,我需要删除空的div标记,Regexp特别询问了一个php解决方案
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
            $("div").each(function()
                {
                if($(this).empty())
                    $(this).remove()
                });
             })
    </script>