开发者

Javascript invalid label error

I am sorry if this question is a repeat of someother. I have looked into some of them but they don't answer my particular question.

I get an "invalid label" error where I am printing my alert statement in the code below:

    $(document).ready(
    function(){
        if( $('map#map').length > 0 ){
            //alert('found a map!');
            $(开发者_Python百科'map#map area').each($area,
                function(i, val){
                    alert('Found: ' + val ):
                }
            );
        }
    }
);

I get the same error is I do the following: alert('Found: ' + $(this) );

Can anyone tell me why this is happening, please?

ps: the elements I am attempting to read are as follows:

<map id="map" name="imgmap20116293122">
<area alt="" coords="11,76,97,127" href="" shape="rect" target="" title="" />
<area alt="" coords="12,28,96,74" href="" shape="rect" target="" title="" />
<area alt="" coords="100,28,160,73" href="" shape="rect" target="" title="" />
<area alt="" coords="162,28,221,73" href="" shape="rect" target="" title="" />
<area alt="" coords="502,239,549,282" href="" shape="rect" target="" title="" />
<area alt="" coords="473,284,554,330" href="" shape="rect" target="" title="" /-->


You've got a : instead of a ; at the end of the line. Change

alert('Found: ' + val ):

to

alert('Found: ' + val );

See also label @ MDC docs.


You have a colon at the end of the statement. Change that to a semicolon.

Also, you have an extra parameter $area in the each method, which is not supported. If you remove that, the code will run.


You put a colon in stead of a semicolon:

alert('Found: ' + val );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜