jQuery类型错误:id为null [英] Jquery Type error : id is null

查看:199
本文介绍了jQuery类型错误:id为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我正在使用的脚本,但它给我错误类型错误:x为空.

This is the script i m using but it is giving me error Type Error: x is null.

 <script type="text/javascript"> 
    var $j = jQuery.noConflict();
    $j(function()
    {
      if (entityId != null && entityId != "")
      {
        var x=document.getElementById("my_act");
        alert(x.innerHTML);
      }
    });
</script>

推荐答案

运行此脚本时,页面上没有ID为my_act的元素.

There is no element with an ID of my_act on the page when this script is run.

此外,如果您使用的是jQuery,为什么不实际使用jQuery并使用$("#my_act")而不是document.getElementById("my_act")

Also, if you are using jQuery why not actually use jQuery and do $("#my_act") instead of document.getElementById("my_act")

这篇关于jQuery类型错误:id为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆