- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试获取我单击的图标的样式,以便获取其翻译值。我这样做是因为我想创建一个 div,它在 map 上的位置与点击的图标相同。到目前为止,这是我的网站: http://www.david-halfon.com/radio/index.html
基本上,每当有人按下黄色圆圈时,它周围就会出现一个 div。
这是单击图标时发生的事件的代码:
locale.on('click', function(e) {
$("#music").attr("src", prop.Url);
$(".player").show();
play();
sendWithAjax(prop.Country, prop.City);
$("h1").html(prop.Station);
$("h2").html(prop.Country);
$("h3").html(prop.City);
//console.log($(this).css("transform"));
//console.log($(this).attr("style"));
console.log($(this));
setTimeout(function(){ $("h4").html(globalVar);}, 500);
$(".plusB").show();
$(".shareB").show();
map1.setView(locale.getLatLng(), 4);
playNow = prop.Station;
playNowCountry = prop.Country
playNowCity = prop.City;
});
评论是我到目前为止尝试做的,但它似乎不起作用。
当我尝试 consloe.log(this) 时,我得到“未定义”。
谢谢!!
最佳答案
您没有得到预期的 $(this).css(...)
的原因信息是 this
不是常规的 DOM 对象,因为使用 Firebug 可以清楚地显示它:
<img>
你想从中获取样式包含在 _icon
中此对象的成员,因此您可以使用例如:
console.log($(this._icon).css('transform'));
console.log($(this._icon).attr('style'));
// and so on
这种方式(在您的网站上使用 Firebug 进行测试)效果很好。
顺便说一句,我不明白为什么点击事件的目标是这个对象而不是 <img>
...
顺便说一句,这个网站是个好主意:太棒了!
关于javascript - 获取我在 mapbox 中点击的标记的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31231322/
menu Home Events Technical Schedule
我试图阻止触发默认 anchor 链接和 onclick 事件。 这是 HTML 代码: Google 我正在尝试使用以下 jQuery 代码阻止任何重定向的发生: $("#mylink").cli
我想在单击父 div 上的任意位置时切换我的 div,除非单击 anchor 元素。因此,例如,如果我单击示例中的第一个文本,我希望它切换,但在我的示例中的第二个文本上,我不希望它切换。 JSFidd
我在通过 jQuery 伪造 anchor 点击时遇到问题:为什么我的thickbox在我第一次点击输入按钮时出现,但第二次或第三次却没有出现? 这是我的代码: Link 当我直接点击链接时,它总是
我已经从 Mootools 切换到 jQuery,因为我认为它有更好的支持。我有这样的 HTML: Opcje Opcje Opcje Opcje Opcje Opcje Opcje JS
我是一名优秀的程序员,十分优秀!