Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 HTML 中,我有一个对象标签,如下所示:
<OBJECT ID="objectid" CLASSID="some-class-id" CODEBASE="some-codebase">
我用 JavaScript 编写了一个函数来访问这个对象。
我检查了空值如下:
if(objectid==null){-----}
我想检查对象是否未定义或为空。我们有什么功能可以检查吗?
要检查变量是否包含值并存在,请使用:
if (variable) {}
例如,要检查您是否已获取objectidDOM 元素:
objectid
if (document.getElementById("objectid")) {}