PHP或JQuery或CSS(在wordpress中)-显示表数据时显示Div


PHP or JQuery or CSS (in wordpress)- Show Div when Table data is displayed

我在一个wordpress网站上使用灵活的地图插件。这个插件有一个表单,允许用户输入他们的"从地址"来获得地图上显示的位置的方向。表单没有ID或类(我无法添加)。

我希望用户能够打印方向一旦表单提交,但我不希望打印按钮显示,直到方向显示从用户按下提交按钮。

方向显示在一个表中,所以我想我可以使用JQuery说,当表显示时,然后显示打印div。

我认为它是这样的东西,但我不确定如何格式化它基于表(因为表单没有ID):

jQuery(document).ready(function($) {
 $('#idOfYourForm').on("submit", function () {
$('#print').show();
});
});

欢迎任何建议!

EDIT以下是按下方向提交按钮后生成的代码:

<div id="my-dir-div" style="float: left; direction: ltr;">
<form>
<p>
<input type="text" name="from">
<input type="submit" value="Get Directions">
</p>
</form>
<div jstcache="0">
<div class="adp-warnbox" jsdisplay="warnings.length" jstcache="1" style="display: none;">
<div class="warnbox-c2" jstcache="0"></div>
<div class="warnbox-c1" jstcache="0"></div>
<div class="warnbox-content" jscontent="$this" jsselect="warnings" jstcache="5"></div>
<div class="warnbox-c1" jstcache="0"></div>
<div class="warnbox-c2" jstcache="0"></div>
</div>
<div jseval="setupPanelStep(this, $waypointIndex)" jsvalues="$waypointIndex:0;" jsselect="legs[0].start_address" jstcache="2">
<table id="adp-placemark" class="adp-placemark" jstcache="0">
<tbody jstcache="0">
<tr jstcache="0">
<td jstcache="0">
<img jsvalues=".src:markerIconPaths[$waypointIndex]" jstcache="14" src="http://maps.gstatic.com/mapfiles/markers2/icon_greenA.png">
</td>
<td class="adp-text" jscontent="$this" jstcache="12">211 South Elson Street, Kirksville, MO 63501, USA</td>
</tr>
</tbody>
</table>
</div>
<div jsvalues="$legIndex:$index;" jsselect="legs" jstcache="3" jsinstance="*0">
<div class="adp-legal" jscontent="copyrights" jstcache="4">Map data ©2013 Google</div>
</div>
</div>
<div id="print">
<input id="print" class="printbtn" type="button" value="Print Directions" onclick="return pop_print()">
<script type="text/javascript">
function pop_print(){
w=window.open(null, 'Print_Page', 'scrollbars=yes');
w.document.write(jQuery('div#my-dir-div').html());
w.document.close();
w.print();
}
</script>
</div>

我认为你可以试试这个(只有当id为adp-placemark的表在页面上可用,然后显示它)

$(function(){
    if($('#my-dir-div table#adp-placemark').length) $('#print').show();
});

或者这个

$(function(){
    if($('#my-dir-div table#adp-placemark td.adp-text').length) $('#print').show();
});