doutouman6245 2013-01-17 04:50
浏览 33
已采纳

使用PHP,AJAX中的jQuery / JavaScript隐藏父ID

Okay, I'm calling a PHP using Ajax for a file upload.

else if (in_array($file_extn, $allowed)=== false){
            echo '<script type = "text/javascript">window.alert("The only file types allowed are .jpg, .gif, .png");</script>';
            echo '<script type = "text/javascript">$(document).ready(function(){$.parent("#loadimg").fadeOut();});</script>';
        }

The alert works no problem but the second echo isn't working. It is not fadingOut the ID. What is the problem?

  • 写回答

3条回答 默认 最新

  • dongshi1207 2013-01-17 04:53
    关注

    You need a selector to tell jQuery what to get the parent() of.

    $(document).ready(function() {
        $(".childElement").parent("#loadimg").fadeOut();
    });
    

    See: http://api.jquery.com/parent/

    Note the first line of the first paragraph, "Given a jQuery object that represents a set of DOM elements..."

    If you're trying to fade out #loadimg, then try this:

    $(document).ready(function() {
        $("#loadimg").fadeOut();
    });
    

    And if you're trying to fade the parent of #loadimg:

    $(document).ready(function() {
        $("#loadimg").parent().fadeOut();
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 socket通信实现多人聊天室疑惑
  • ¥15 DEV-C++编译缺失
  • ¥33 找熟练码农写段Pyhthon程序
  • ¥100 怎么让数据库字段自动更新
  • ¥15 antv g6 力导向图布局
  • ¥15 quartz框架,No record found for selection of Trigger with key
  • ¥15 锅炉建模+优化算法,遗传算法优化锅炉燃烧模型,ls-svm会搞,后面的智能算法不会
  • ¥20 MATLAB多目标优化问题求解
  • ¥15 windows2003服务器按你VPN教程设置后,本地win10如何连接?
  • ¥15 求一阶微分方程的幂级数