我有一段代码正在读取购物篮中有多少物品,我想将一个类添加到一个 ID 为 #basket_count 的 div 中。我知道如何在出现计数器时向 span 标签添加一个类。不知道如何从这里开始,任何帮助将不胜感激。
$('span#ctl00_lblItems').filter(function (index) {
return parseInt(this.innerHTML) > 0;
}).addClass("green");
Run Code Online (Sandbox Code Playgroud) 我正在制作我的第一个谷歌地图,地图的目的是显示一个城市中的各种标记,但地图应该放大到我在代码中设置的标记。
到目前为止,我已经一切正常,但我无法弄清楚如何缩放到特定标记,在地图居中并适合所有标记的那一刻。下面是我的代码:
<script>
jQuery(function($) {
// Asynchronously Load the map API
var script = document.createElement('script');
script.src = "http://maps.googleapis.com/maps/api/js?sensor=false&callback=initialize";
document.body.appendChild(script);
});
function initialize() {
var map;
var bounds = new google.maps.LatLngBounds();
var mapOptions = {
mapTypeId: 'roadmap'
};
// Display a map on the page
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
map.setTilt(45);
// Multiple Markers
var markers = [
['Elements ll at McConachie, Edmonton', 53.634976,-113.426110],
['Creekwood Landing, Edmonton', 53.399758,-113.280340],
['Heritage Valley Station, Edmonton', 53.403244,-113.538686],
['Walker Lake Gate, Edmonton', 53.420672,-113.421288],
['Rutherford Landing, Edmonton', …Run Code Online (Sandbox Code Playgroud)