我有以下带有jQuery代码的HTML:
<div id="info" style="width: 100%; height: 280px; overflow-y: scroll;"></div>
var url1 = cbcWMS1.getGetFeatureInfoUrl
(evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'text/html'});
$('#info').append('<iframe width="99%" seamless src="' + url1 + '"</iframe>');
字符串url1
返回带有元素的表的iframe
元素。
如何访问iframe
?
我想添加一个条件,如果iframe
缺少内容,则可以使用jQuery隐藏整个<div id='info'>
。
字符串:url1
包含以下代码:
<body>
<table class="table table-hover table-condensed">
<h3>${type.name}</h3>
<head>
<tr>
<#list type.attributes as attribute>
<#if !attribute.isGeometry>
<th>${attribute.name}</th>
</#if>
</#list>
</tr>
</head>
<body>
<#assign odd = false>
<#if odd>
<tr class="odd">
<#else>
<tr>
</#if>
<#assign odd = !odd>
<#list features as feature>
<#list feature.attributes as attribute>
<#if !attribute.isGeometry>
<td>${attribute.value}</td>
</#if>
</#list>
</tr>
</#list>
</body>
答案 0 :(得分:1)
我已经解决了更改我的代码的以下部分的问题:
{'INFO_FORMAT': 'text/html'}
至{'INFO_FORMAT': 'application/json'}
。
现在,网址代表JSON
而非HTML
。
因此,检查和使用数据肯定更容易。
答案 1 :(得分:0)
获取当前匹配组中每个元素的后代 元素,由选择器,jQuery对象或元素过滤。
element = $("#info").find("#iframe_id").contents()