如何在使用Jquery打开另一个iframe后关闭一个iframe

时间:2015-09-30 21:06:48

标签: javascript jquery html iframe

我在一个网站的职业页面上有2个iframe,客户端已经向我提供了iframe,他们的开放位置来自iframe。我已将其设置为当您点击链接或图像时,iframe通过.toggle()打开和关闭; 这是我的代码:

<div class="OpenPositions-left">
    <div class="position-city">
        <h2><a href="<?php the_field('view_positions_link_left'); ?>"    class="ny-positions"><?php the_field('position_city_left'); ?></a></h2>
</div>
<a href="<?php the_field('view_positions_link_left'); ?>" class="ny-positions">
    <img src="<?php the_field('open_positions_left'); ?>" />
</a>
<a href="<?php the_field('view_positions_link_left'); ?>" class="ny-positions"><?php the_field('view_positions_left'); ?></a>
</div><!-- end of open positions left -->
<div class="OpenPositions-right">
<div class="position-cityRight">
    <h2><a href="<?php the_field('view_positions_link_right'); ?>"     class="rus-positions"><?php the_field('position_city_right'); ?></a></h2>
    </div>  
     <a href="<?php the_field('view_positions_link_right'); ?>" class="rus-positions">
    <img src="<?php the_field('open_positions_right'); ?>" />
    </a>
    <a href="<?php the_field('view_positions_link_right'); ?>" class="rus-positions"><?php the_field('view_positions_right'); ?></a>    
    <script type="text/javascript" src=""></script>
    <div id="iframeHeightDiv" name="" align="center" class="newyork-iframe openjobs-container">
     <iframe id="inlineframe" name=""src="" frameborder="0" allowtransparency="true" sandbox="allow-forms allow-scripts allow-same-origin">   </iframe>
    </div><!-- end of iframe -->
    <div id="hr" class="rushr openjobs-container">
    <script src="second-ifrmae.php"></script>
</div><!-- end of bamboohr -->
</div><!-- end of OpenPositions -->

<script>
jQuery(document).ready(function($) {
    $('div.openjobs-container').each(function() {
        var $OpenJobs = $(this);    
        $('openjobs-container', $OpenJobs).click(function(e) {
            e.preventDefault();
            $div = $(div.'openjobs-container').not($div).hide();
            return false;
        });

    });

});



</script>

代码没有提出任何建议?

1 个答案:

答案 0 :(得分:0)

您在此代码块中遇到问题:

$sql = "SELECT * FROM members ORDER BY name";   // Database query and results
$result = mysqli_query($connection, $sql);

if ( $result == false )
{
      // handle error with mysqli_... functions
}
else
{
     while($row = mysqli_fetch_array($result)) {
     ...

这行代码中的选择器:

$('openjobs-container', $OpenJobs).click(function(e) {
    e.preventDefault();
    $div = $(div.'openjobs-container').not($div).hide();
    return false;
});

应该是一个字符串:

$div = $(div.'openjobs-container').not($div).hide();