English 中文(简体)
我的所有法典都由最后一节起草。
原标题:All my code is being overwritten by the last section
  • 时间:2011-07-27 20:47:40
  •  标签:
  • javascript

我们有一个地图,利用多种渠道在各国上空制造超支。 当一个用户对一个国家 时,多角会改变肤色。

当摩擦离开该国时,它会回来(或至少我们希望它)

下面的守则是,两国都利用《刑法》最后一节为联合司法提供场所。 看来所有其他法典都已经过时。

我不知道有哪一个变数可以独一无二。

for(var i = 0; i < germany.length; i++){
    addListener( germany[ i ], germany );
    }
function addListener( germany_item, tweened )
{   
    google.maps.event.addListener(germany_item, "mouseover",function() {
                    for( var i in tweened ) 
        tweened[ i ].setOptions({ fillColor: "#DD732B", strokeColor: "#DD732B" });
    });
    google.maps.event.addListener(germany_item, "mouseout",function() {
                    for( var i in tweened ) 
        tweened[ i ].setOptions({ fillColor: "#5EA9BD", strokeColor: "#5EA9BD" });
    });
}//
for(var i = 0; i < france.length; i++){
    addListener( france[ i ], france );
    }
function addListener( france_item, tweened )
{   
    google.maps.event.addListener(france_item, "mouseover",function() {
                    for( var i in tweened ) 
        tweened[ i ].setOptions({ fillColor: "#DD732B", strokeColor: "#DD732B" });
        });
    google.maps.event.addListener(france_item, "mouseout",function() {    
                    for( var i in tweened ) 
            tweened[ i ].setOptions({ fillColor: "#006886", strokeColor: "#006886" });
        });
最佳回答

您不能有两种功能,其名称相同(有两份<代码>>功能添加()。 如果你这样做,那么,只有最后一点才会积极(这是你所经历的)。 我建议你要么把这两项职能的名称改为addListener Germany(Liaddstener France(),要么用一种功能取代这两种功能,将两者作为参数的细微差别加以替换,以便你能够用一种代码来满足这两种需要。

例如,你可以改变这一方向:

for (var i = 0; i < germany.length; i++) {
    addListenerCommon( germany[ i ], germany , "#5EA9BD", "#5EA9BD");
}

for(var i = 0; i < france.length; i++) {
    addListenerCommon( france[ i ], france, "#006886", "#006886" );
}

function addListenerCommon(item, tweened, fill, stroke ) {   
    google.maps.event.addListener(item, "mouseover",function() {
        for( var i in tweened ) {
            tweened[ i ].setOptions({ fillColor: "#DD732B", strokeColor: "#DD732B" });
        }
    });
    google.maps.event.addListener(item, "mouseout",function() {
        for( var i in tweened ) {
            tweened[ i ].setOptions({ fillColor: fill, strokeColor: stroke });
        }
    });
}

如果你重新加入更多的国家,那么你就能够发挥 lo的作用:

function initCountry(country, fill, stroke) {
    for (var i = 0; i < country.length; i++) {
        addListenerCommon(country[i], country, fill, stroke);
    }
}

initCountry(germany, "#5EA9BD", "#5EA9BD");
initCountry(france, "#006886", "#006886");
initCountry(australia, "#FF6886", "#FF6886");

目 录

问题回答




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

热门标签