[英]Not able to perform any event after image click?
This is my code which is getting dynamically appended by a plugin 这是我的代码,正在由插件动态附加
<div class="emoji-menu" style="top: 913px; left: 1211.5px; display: block;">
<div class="emoji-items-wrap1">
<div class="emoji-items-wrap nano mobile_scrollable_wrap has-scrollbar">
<div class="emoji-items nano-content" tabindex="-1" style="right: -17px;">
<a href="javascript:void(0)" title=":unamused:">
<img src="img/blank.gif" class="img" style="display:inline-block;width:20px;height:20px;background:url('img/emojisprite_0.png') -360px 0px no-repeat;background-size:540px 140px;" alt=":unamused:">
<span class="label">:unamused:</span>
</a>
<a href="javascript:void(0)" title=":joy:">
<img src="img/blank.gif" class="img" style="display:inline-block;width:20px;height:20px;background:url('img/emojisprite_0.png') -440px 0px no-repeat;background-size:540px 140px;" alt=":joy:">
<span class="label">:joy:</span>
</a>
</div>
</div>
</div>
</div>
The problem is that i need to change .emoji-menu's div property to display:none whenever the img tag inside it gets clicked(please refer the code), I have tried with different selectors but it didn't work. 问题是我需要将.emoji-menu的div属性更改为display:none,只要单击其中的img标签(请参考代码),我就尝试使用不同的选择器,但它不起作用。
I think <a href="javascript:void(0)"
is causing problem. 我认为
<a href="javascript:void(0)"
引起了问题。 Please help me on this. 请帮我。
With angular you can use ngClick and ngShow for these things: 使用angular可以将ngClick和ngShow用于以下用途:
<div ng-show="thisEmoji" class="emoji-menu" style="top: 913px; left: 1211.5px; display: block;">
<div class="emoji-items-wrap1">
<div class="emoji-items-wrap nano mobile_scrollable_wrap has-scrollbar">
<div class="emoji-items nano-content" tabindex="-1" style="right: -17px;">
<img ng-click="thisEmoji = true" src="img/blank.gif" class="img" style="display:inline-block;width:20px;height:20px;background:url('img/emojisprite_0.png') -360px 0px no-repeat;background-size:540px 140px;" alt=":unamused:">
<span class="label">:unamused:</span>
<img ng-click="thisEmoji = true" src="img/blank.gif" class="img" style="display:inline-block;width:20px;height:20px;background:url('img/emojisprite_0.png') -440px 0px no-repeat;background-size:540px 140px;" alt=":joy:">
<span class="label">:joy:</span>
</div>
</div>
</div>
</div>
The a tag could be replaced with removed as it only ads a title to the element. 标记可以替换为删除,因为它仅广告元素的标题。 I seem to rememeber the alt attribute on img does the same.
我似乎记得img的alt属性也做同样的事情。
If your html snippet appends the document dynamically, you should bind the click events of images . 如果您的html代码段动态附加了文档,则应绑定images的click事件。 Hope this helps
希望这可以帮助
$("body").on("click",".emoji-items img",function(){
$(".emoji-menu").fadeOut();
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.