首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自举模态onmouseover

自举模态onmouseover
EN

Stack Overflow用户
提问于 2015-02-03 06:08:48
回答 1查看 8.5K关注 0票数 0

因此,我正在我的个人网页工作,这是我的第一次开发与启动。我使用php、html、css和JS作为开发堆栈。我遇到的错误是创建一个元素: 1.如果php测试通过,创建一个div,在JS中附加一个onemouseover事件(我知道如何做这件事) 2。我想要一个引导模式来打开和转换onmouseoever,并关闭,onmouseleave。到目前为止,这是代码,createModal函数是空的,因为使用this.innerHTML = blahblahblah没有工作。

代码语言:javascript
复制
        <?php 
        if(!isset($_GET["nfc"])){
            $nfc = false;
        } else {
            $nfc = filter_var($_GET["nfc"], FILTER_VALIDATE_BOOLEAN);
        }
    ?>

<?php 
        if ($nfc == true) { ?>
            <a href="#"
            id="nfc"
            data-toggle="modal"
            data-target="#basicModal"><i class="fa fa-chevron-circle-down fa-5x"></i></a>
            <div class="modal fade" id="basicModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&amp;times;</button>
                        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
                        </div>
                        <div class="modal-body">
                            <h3>Modal Body</h3>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                            <button type="button" class="btn btn-primary">Save changes</button>
                        </div>
                    </div>
                </div>
            </div>
        <?php } else { ?>
            <i class="fa fa-chevron-circle-down fa-5x"></i>
        <?php } ?>
    </div>

JS: var元素= document.getElementById("nfc");if (typeof(元素) != 'undefined‘& element != null) { element.onmouseover = createModal;}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-03 06:53:35

可以使用以下jquery代码显示隐藏模式

代码语言:javascript
复制
$(document).ready(function(e){
  $("body").find("#nfc").hover(function() {
      $("#basicModal").modal('show');
  }, function(){
      $("#basicModal").modal('hide');                            
  });
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28292437

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档