jQuery的CSS显示div? [英] Jquery css show div?

查看:87
本文介绍了jQuery的CSS显示div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这是我的问题,没有人能够回答。我有两个使用的JavaScript。我有一次弹出,并告诉它在关闭时保持关闭24小时。另一种方法是在页面上放置一个链接以显示该弹出窗口,直到刷新并保持隐藏状态,直到cookie过期。现在div弹出窗口被设置为 display:none 。该cookie告诉它显示直到关闭按钮被按下。无论我在javascript中怎样重做,以便从链接暂时显示弹出窗口,它都不会显示。一些cookie javascript将如何被修改,因此必须在弹出的div上删除css: display:none 。我不知道该怎么办。



这是当前的代码:






 < script type =text / javascript> 
$(#linkshow)。click(function {
$(#window)。show()
});
< / script>

< a href =#id =linkshow>提交评论< / a>
< div id =window>
...
< div>
< script type =text / javascript>
... cookie关闭时隐藏24小时
< / script>

注意:我已经试过了:

<$ (函数(e){
e.preventDefault();})。
$(#window)。show();
});
});

和...

  $(document).ready(function(){
$(#window)。hide();

$(#linkshow)。 live('click',function(e){
e.preventDefault();
$(#window)。show();
});
}) ;

和...



<$ p $点击(函数(){
$(#window)。show()$ b $(#$ b $($#$ b $(#linkshow b});
});

和...

 < div id =windowstyle =display:none;> 

 < div id =window> 






然后另一个24小时的cookie不保留隐藏的弹出窗口。我假设我需要取出 id =windowstyle =display:none; 以及一些javascript cookie在底部的代码,以便隐藏当被要求隐藏24小时,并显示需要时显示在当前页面上,直到刷新,但我在空白的做什么。

解决方案

你需要将你的代码包装在一个DOM准备好的处理程序中,并且你也错过了函数声明后的括号。试试这个:

 < $ c $< script type =text / javascript> 
$(function(){
$(#linkshow)。click(function(){
$ (#window)。show()
});
});
< / script>


Ok this is my problem that no one can seem to answer. I have two javascripts in use. Once is for the popup I have and tells it to stay closed for 24hrs when closed. The other is to put a link some where on the page to display this popup until refreshed and kept hidden till the cookie expires. Now the div popup is set to display:none. The cookie tells it to be shown until the close button is pressed. No matter what I seem to rework in my javascript to tempoarly show the popup from a link, it will not show. Some how the cookie javascript is going to have to be modified and thus having to remove css:display:none on the popup div. I have no idea what to do.

This is the current code:


<script type="text/javascript"> 
$("#linkshow").click(function {
$("#window").show()
});        
</script>

<a href="#" id="linkshow">Submit a comment</a>
<div id="window">
...
<div>
<script type="text/javascript">
...cookie popup hide for 24hr on close
</script>

Note: I have already tried:

$(document).ready(function() {
   $("#linkshow").click(function(e) {
      e.preventDefault();
      $("#window").show();
   });
}); 

and...

$(document).ready(function() {
     $("#window").hide();

   $("#linkshow").live('click', function(e) {
      e.preventDefault();
      $("#window").show();
   });
}); ​

and...

$(function() {
        $("#linkshow").click(function() {
            $("#window").show()
        });        
    });

and...

<div id="window" style="display:none;">

to

<div id="window">


Then the other 24hr cookie javascript doesn't keep the popup hidden. I am assuming I need to take out the id="window" style="display:none; and some how advanced the javascript cookie at the bottom the code so it will hide when asked to be hidden for 24hr and show when needed to be shown on the current page until refresh but I am at blank on what to do.

解决方案

You need to wrap your code in a DOM ready handler, and you also missed the brackets following the function declaration. Try this:

<script type="text/javascript"> 
    $(function() {
        $("#linkshow").click(function() {
            $("#window").show()
        });        
    });
</script>

这篇关于jQuery的CSS显示div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆