小编Tib*_*bor的帖子

更改鼠标悬停在 div 上的标记图标

当用户将鼠标悬停在 div 标签上时,我想更改标记图标。我找到了一个接近的解决方案,当用户将鼠标悬停在标记本身上时,标记图标会发生变化。但我想使用 div 标签来更改它。

代码:

var icon1 = "imageA.png";
var icon2 = "imageB.png";

var marker = new google.maps.Marker({
    position: myLatLng,
    map: map,
    id: 1,
    icon: icon1,
    title: "some marker"
});

google.maps.event.addListener(marker, 'mouseover', function() {
    marker.setIcon(icon2);
});
google.maps.event.addListener(marker, 'mouseout', function() {
    marker.setIcon(icon1);
});
Run Code Online (Sandbox Code Playgroud)

我的设置应如下所示:

   <div class="sth" onmouseover="ShowMarker(id)" />
Run Code Online (Sandbox Code Playgroud)

我的 JS 类似:

    var icon1 = "imageA.png";
    var icon2 = "imageB.png";

    var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        id: 1,
        icon: icon1,
        title: "some marker"
    });

    function ShowMarker(id) {
    google.maps.event.addListener(marker, …
Run Code Online (Sandbox Code Playgroud)

javascript jquery google-maps google-maps-api-3

2
推荐指数
1
解决办法
5406
查看次数

使用href而不是输入

我有一个AJAX函数,我在AJAX上很糟糕.我想将值从PHP传递给AJAX.我设法通过使用:

<input type="text" id="price" onclick='ajaxFunction()' value="<?php echo $id; ?>" />
Run Code Online (Sandbox Code Playgroud)

然后在我的AJAX中:

document.getElementById('price').value;
Run Code Online (Sandbox Code Playgroud)

但我想通过使用HTML a href使其工作.

任何人都可以帮我找到可行的方法吗?

提前致谢!

html javascript php jquery

0
推荐指数
1
解决办法
96
查看次数

标签 统计

javascript ×2

jquery ×2

google-maps ×1

google-maps-api-3 ×1

html ×1

php ×1