English 中文(简体)
在 Java文中,我如何在某一时间只展示一个要素
原标题:In JavaScript how would I show only one element at a time

我制定了这一简便的Java文本,使用户能够点击内容,然后向用户显示隐藏的东西。

然而,现在我的法典允许用户点击所有要素,同时披露这些内容。

我想知道,谁能把我推向正确的方向?

http://jsfiddle.net/MTJa5/ rel=“nofollow”

var hellos = function(){
    var divClicks = document.getElementsByClassName("clickToShow");
    for(i=0; i < divClicks.length; i++){
        var click = divClicks[i];

        var close = function(){
            var open = false;

            click.addEventListener("click", function(e){
            e.preventDefault();
                if(open){
                    this.childNodes[3].setAttribute("class", "hidden");
                    open = false;
                } else {
                    this.childNodes[3].setAttribute("class", "show");
                    open = true;
                }
            },false);
        }();
    }
}();
最佳回答

http://jsfiddle.net/MTJa5/22/“rel=“nofollow”

问题回答

hi buddy gone through your fiddle work and found the below solution..

这完全是你在修改过程中的缩略语:

var hellos = function(){
    var divClicks = document.getElementsByClassName("clickToShow");
    for(i=0; i < divClicks.length; i++){
        var click = divClicks[i];


        var close = function(){
            var open = false;
            click.addEventListener("click", function(e){
                var divVisible= document.getElementsByClassName("show");
        //alert(divVisible.length);
        for(j=0; j < divVisible.length; j++){
            divVisible[j].setAttribute("class", "hidden");
        }

            e.preventDefault();
                if (open){
               this.childNodes[3].setAttribute("class", "hidden");
                    open = false;
                }else{
                    this.childNodes[3].setAttribute("class", "show");
                    open = true;
                }

            },false);
        }();
    }
}();

Here is the explaination::

页: 1

i) 设置<条码>=hidden 接着,你们的法典又处理 st问题,在点击时显示各自干 the。

当你出示任何内容时,你必须穿过其他 d子,隐藏其内容。

EDIT: see this fiddle: http://jsfiddle.net/spb_/MTJa5/25/





相关问题
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.

热门标签