我想将我从id获得的值转换为数字并添加一个,然后将新值传递dosomething()给要使用的函数.当我尝试这个并且价值是1时我得到的回报11而不是2.
$('.load_more').live("click",function() { // When user clicks
var newcurrentpageTemp = $(this).attr("id") + 1;// Get id from the hyperlink
alert(parseInt(newcurrentpageTemp));
dosomething();
});
Run Code Online (Sandbox Code Playgroud) 在 ColdFusion 中我可以看到下面的代码,但它似乎不起作用。我想确保仅当有效的起始日期和截止日期在范围内时才应用折扣,请参见下文。
if (
DATEDIFF("d", discount.ValidFrom(), now()) >= 0
AND
DATEDIFF("d", now(), discount.ValidTo()) <= 0
){
// ALL OK Accept Discount
}
else
{
// Discount is no Longer Valid boo!
}
Run Code Online (Sandbox Code Playgroud) 示例1中的代码有效.我想了解marker.setIcon(); 功能更多(也是JavaScript新手).
我的问题是.在Google地图的文档中,您可以看到更改标记的内容.
MarkerImage(url:string, size?:Size, origin?:Point, anchor?:Point, scaledSize?:Size)
Run Code Online (Sandbox Code Playgroud)
这与我在示例1中为设置标记Icon所做的事情有什么关系呢?我已经做过像这样的事了吗?
marker = google.maps.MarkerImage({
url: "newIcon.png"
});
marker.setIcon(marker);
Run Code Online (Sandbox Code Playgroud)
那有用吗?
这是我的榜样
例1
function initialize(){
//MAP
var latlng = new google.maps.LatLng('xxx','xxx');
var options = {
zoom: 16,
center: latlng,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
map = new google.maps.Map(document.getElementById("map_canvas"), options);
//GEOCODER
geocoder = new google.maps.Geocoder();
marker = new google.maps.Marker({
map: map,
draggable: true
});
marker.setPosition(latlng);
marker.setIcon("newIcon.png");
map.setCenter(latlng);
}
Run Code Online (Sandbox Code Playgroud) 我的谷歌地图标记不会第一次加载(但它确实以地址为中心),除非我将以下代码添加到底部...
marker.setPosition(latlng);
Run Code Online (Sandbox Code Playgroud)
为什么会这样?在我测试的FF,IE和Chrome等所有浏览器中都是一样的
谢谢你的帮助.
var geocoder;
var map;
var marker;
function initialize(){
//MAP
var latlng = new google.maps.LatLng('xxxxx','xxxxx');
var options = {
zoom: 16,
center: latlng,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
map = new google.maps.Map(document.getElementById("map_canvas"), options);
//GEOCODER
geocoder = new google.maps.Geocoder();
markerImg = google.maps.MarkerImage({
url: "newIcon.png"
});
marker = new google.maps.Marker({
map: map,
icon: markerImg,
draggable: true
});
;
}
$(document).ready(function() {
initialize();
etc
Run Code Online (Sandbox Code Playgroud)