jQuery插件101

时间:2014-02-06 01:12:48

标签: javascript jquery html

我是这一切的新手,但在搜索教程等之后,我不明白为什么这个(以及我在我的代码中粘贴的每个其他JScript插件*)都没有工作。

*在HTML本身和单独的JS文件中......

<html>
<head>

<link rel="stylesheet" type="test/css" href="stylesheet.css"/>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>

<body>
<div class="imgContent"><div id="map"><script type="text/javascript">
$('#map').mobilymap({
    position: 'center', // map position after loading - 'X Y', 'center', 'top left', 'top right', 'bottom left', 'bottom right'
    popupClass: 'bubble',
    markerClass: 'point',
    popup: true, // show popup on marker click - true/false
    cookies: true, // remember last map position - true/false
    caption: true, // show caption - true/false
    setCenter: true, // sets the map view to the center on marker click
    navigation: true, // display buttons to pan in four directions
    navSpeed: 1000, // speed of panning map (higher value for slow panning)
    navBtnClass: 'navBtn',
    outsideButtons: false, // selector, only anchors eg. '.map_buttons a'
    onMarkerClick: function(){}, // call the function on marker click (popup must be disabled)
    onPopupClose: function(){}, // call the function after popup closing
    onMapLoad: function(){} // call the function after loading map
});
</script></div></div>
</body>
</html>

他们看起来并没有这样,并且已经在本地和服务器上进行了尝试,但反复出现的主题是它们都没有工作(地图插件)。

请放心,我知道我错过了一些基本的东西,我只是不知道它是什么!

1 个答案:

答案 0 :(得分:0)

您已将script标记放在中,您要修改的元素。在<{strong> map div:

之后移动脚本标记
<div class="imgContent">
    <div id="map">
    </div>
    <script src="path/to/your/scripts/mobilymap.js"></script>
    <script>
    $('#map').mobilymap({
        position: 'center', // map position after loading - 'X Y', 'center', 'top left', 'top right', 'bottom left', 'bottom right'
        popupClass: 'bubble',
        markerClass: 'point',
        popup: true, // show popup on marker click - true/false
        cookies: true, // remember last map position - true/false
        caption: true, // show caption - true/false
        setCenter: true, // sets the map view to the center on marker click
        navigation: true, // display buttons to pan in four directions
        navSpeed: 1000, // speed of panning map (higher value for slow panning)
        navBtnClass: 'navBtn',
        outsideButtons: false, // selector, only anchors eg. '.map_buttons a'
        onMarkerClick: function(){}, // call the function on marker click (popup must be disabled)
        onPopupClose: function(){}, // call the function after popup closing
        onMapLoad: function(){} // call the function after loading map
    });
    </script>
</div>

您显示的标记也没有mobilymap插件的脚本引用,这显然是个问题。它看起来像一个废弃的插件,虽然有一些项目使用开源的脚本,如下所示:http://code.google.com/p/jqwicket/source/browse/trunk/jqwicket/src/main/java/com/google/code/jqwicket/ui/mobilymap/js/mobilymap.js?r=369