Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.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
使用document.getElementById()访问HTML元素时返回null_Html_Typescript_Grafana - Fatal编程技术网

使用document.getElementById()访问HTML元素时返回null

使用document.getElementById()访问HTML元素时返回null,html,typescript,grafana,Html,Typescript,Grafana,我正在开发Grafana插件。我需要访问module.ts文件中id为的HTML元素。我已使用getElementById()。但它返回null 我的HTML代码: <div name="glg_area" id="glg_area" style="width: 86%; height: 95%; background-color: white; padding: 0px;"> </div> 我通过在.ts文件中导入jquery实现了这一点:

我正在开发Grafana插件。我需要访问module.ts文件中id为的HTML元素。我已使用getElementById()。但它返回null

我的HTML代码:

<div name="glg_area" id="glg_area" style="width: 86%; height: 95%; background-color: white; 
            padding: 0px;">

</div>

我通过在.ts文件中导入jquery实现了这一点:

import $ from "../node_modules/jquery";

console.log('drawing_area ' + $(document.getElementById('glg_area')));

将返回一个空对象:[object object]它是空的

这是否回答了您的问题?这是什么版本的Grafana?一些版本使用AngularJS,更高版本使用React。这使得可能的解决方案因版本而异。我使用的是grafana 6.3.x的最新版本
import $ from "../node_modules/jquery";

console.log('drawing_area ' + $(document.getElementById('glg_area')));