【问题标题】:On Click Dissapear html div单击时消失 html div
【发布时间】:2014-03-01 03:05:33
【问题描述】:

为什么我点击按钮时状态刷新,但按钮消失?

JS

$( ".refreshstatus" ).click(function(){
    $( ".navplayers" ).load('stats.php');
});

CSS

.refreshstatus{
    font-family:'Noto Sans';
    font-weight: 900;
    text-align:center;
    background-color:tomato;
}

HTML

<div class="refreshstatus">Refresh</div>

stats.php

    <?php include ("statsfunction.php"); ?><?php if( ( $Players = $Query->GetPlayers( ) ) !== false ): foreach( $Players as $Player ): ?>                                           
        <img src="https://minotar.net/avatar/<?php echo htmlspecialchars( $Player ); ?>/32"><div class="playerinfo" id="<?php echo htmlspecialchars( $Player ); ?>"><?php echo htmlspecialchars( $Player ); ?></div></img>                                                                  
    <?php endforeach; else: ?>
    No players
    <?php endif; ?>
    <p><b>Players <?php echo "<font color='green' ><?php $players_online ?></font>"  ?> online</b></p>
<div class="col-sm-3 navplayers">
<?php include ("stats.php"); ?>
<div class="refreshstatus">Refresh</div>
</div>  

【问题讨论】:

  • 我猜按钮在状态元素里面?
  • 是导航播放器内的刷新状态
  • 你能给我们展示一下所有的 HTML 吗?心灵感应尚未完善:)
  • @misterManSam - 但我该死的快把它做好了,任何一天。

标签: javascript jquery html css


【解决方案1】:

好的,您的 div.refreshstatus 与您加载的内容重叠。制作一个合适的按钮或使用&lt;a&gt; 链接。

类似...

<div class="col-sm-3 navplayers">
<?php include ("stats.php"); ?>
    <a href="#" class="refreshstatus">Refresh</a>
</div> 

或者一个按钮...

<div class="col-sm-3 navplayers">
<?php include ("stats.php"); ?>
    <button type="button" class="refreshstatus">Refresh</button>
</div> 

【讨论】:

  • 嘿,我自己想通了!我只需要将 div.navplayers 像这样放在单独的 div 中:code
    刷新
  • 这行得通,但最好使用&lt;a&gt;&lt;button&gt;... 特别是如果您希望它可以跨浏览器工作,尤其是旧版浏览器,这些浏览器不能很好地与可点击的@ 配合使用987654328@。强烈推荐!
猜你喜欢
  • 2013-01-14
  • 1970-01-01
  • 2013-02-25
  • 1970-01-01
  • 1970-01-01
  • 2010-12-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多