English 中文(简体)
j 质量功能没有像我计划的那样发挥作用,DIVs在被点击时刚刚消失。
原标题:jQuery function is not working as I planned, DIVs just disappear on click

我在此有一份文字,除一个小细节外,还做了令人吃惊的工作。 它基本上作为点击功能,在某一环节的点击上des掉了某些DIVs。

然而,问题在于,当你在网页上点击ANYWHERE时,你将DIV带走,在你点击一个链接之前留下一个空洞的内容。 显然,这是一个问题。

由于国家排雷局的原因,我不得不使用准确的Im,但我在这里使用的是一纸空文。

仅点击链接看功能,然后在网页上点击其他任何地方(四分点,在白色空间,不管什么)并看一分四。 我知道,这是 Java的口号所说的话,但我不知道如何把点击分解成碎片,这样就没有发生。 此外,如何做到这一点,也使这种四环之内的联系失去作用。

非常感谢任何帮助。 这个网站是一生。

这是我为展示我的基本布局而编辑的原法典。 基本上,一组线上和点击时的链接将DIVS的一个部分改为四部分:

<html>

<head>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    var gLastH = null;
    var gLastId = null;

    $( .toggle ).click(function(e) {
        $( .toggleh:visible ).fadeOut( slow );
        gLastId = $(this).attr( id );
        console.log( #  + gLastId +  h );
        gLastH = $( #  + gLastId +  h );
        $(gLastH).fadeIn( slow );
        e.stopPropagation();
    });

    $( * ).click(function(e) {
        if ($(this).attr( id ) != gLastId) {
            $(gLastH).fadeOut( slow );
        }

        e.stopPropagation();
    });
});
</script>

</head>

<body>
<div id="menubar">
    
    <a href="#" onclick="return false;" class="toggle" id="toggle1" style="display: inline;">
        text here</a>
    <a href="#" onclick="return false;" class="toggle" id="toggle2" style="display: inline;">
        text here</a>
    <a href="#" onclick="return false;" class="toggle" id="toggle3" style="display: inline;">
        text here</a>
    <a href="#" onclick="return false;" class="toggle" id="toggle4" style="display: inline;">
        text here</a>

    <div class="toggleh" id="toggle1h">
        some description in here I suppose
    </div>
   
    <div class="toggleh" id="toggle2h" style="display: none;">
        some description in here I suppose #2dsfds  sdfdsfa sdf 
    </div>
  
    <div class="toggleh" id="toggle3h" style="display: none;">
        some description in here I suppose #3dffdfasdfdsfdfasf
    </div>
   
    <div class="toggleh" id="toggle4h" style="display: none;">
        some description in here I suppose #4 dfdafa
    </div>
</div>

</body>

</html>
最佳回答

<代码>$(* .click(...>)为所有要素(*)设定了点击手。 你可以取消这一职能。

问题回答

这部法律是:

$( * ).click(function(e) {
    if (this.id != gLastId) {
        $(gLastH).fadeOut( slow );
    }

    e.stopPropagation();
});

It selects all of the elements in the document (including html and head and body and attaches a click handler to it. When you click on the document, it compares the id, which likely is empty and then fades out the displayed div.

rel=“nofollow”>Demo。

Not the real expert But this seems to be the faulty part

$( * ).click(function(e) {...............}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签