单击按钮之前显示的Jquery Popup消息?

时间:2012-11-15 21:40:57

标签: jquery modal-dialog bpopup

嗨,我有this code但由于某种原因,在点击按钮之前显示的消息。我不知道为什么会这样。我是新手,所以我一直在尝试不同的东西,但它不能正常工作。我也不知道如何在不同的地方定位它。代码假设是这个

$('element_to_pop_up').bPopup({
            follow: [false, false], //x, y
            position: [150, 400] //x, y
        });

但是当我把它放在那里它根本不起作用。


HTML:

<button id="my-button">POP IT UP</button>
<!-- Element to pop up -->
<div id="element_to_pop_up">
  <div id="popup" style="left: 424.5px; position: fixed; top: 133.5px; z-index: 9999; display: block;">
        <span class="button bClose"><span>X</span></span>
        If you can't get it up use<br>
        <span>bPopup</span>
    </div>
</div>

CSS:

#popup {

    background-color: white;
    border-radius: 10px 10px 10px 10px;
    box-shadow: 0 0 25px 5px #999;
    color: #111;
    display: none;
    min-width: 450px;
    padding: 25px;

}

3 个答案:

答案 0 :(得分:3)

嗯,你在内联css中有display: block;


<div id="popup" 
 style="left: 424.5px; position: fixed; top: 133.5px; z-index: 9999; display: block;">

这会覆盖样式表中的样式,给您带来不愉快的时间。你想删除它:

<div id="popup" 
 style="left: 424.5px; position: fixed; top: 133.5px; z-index: 9999;">

解释:

您的弹出窗口display: block;属性中的css中有style

你需要删除,然后真正的CSS中的display: none将会在应有的位置启动。

演示:http://jsfiddle.net/uRVaf/4/

答案 1 :(得分:0)

您可以使用onclickonsubmit;

之类的内容
<input type="button" name="button" value = "submit" onclick="POPup()"  />

你的javaScript代码就像

<script type="text/javascript">

function POPup(){
//.... your pop up code goes here
}
</script>

答案 2 :(得分:-1)

将此添加到您的css

#element_to_pop_up {display:none;}

这是小提琴

FIDDLE