capty 插件中的单击处理程序
我正在 jquery capty 插件 中尝试这个JS代码。然而,该插件需要一个图像才能工作,例如:
<img id="default1" src="img/1.jpg" name="#content-target1" width="208" height="143" class="latest_img" />
好吧,当我添加此图像时,下面的 JS 不起作用。基本上我想要的只是单击跨度并显示带有内容的警报消息。
$('.tag_content').live('click', function(event){
var span_val = $(this).parent().children("span").html();
alert(span_val);
});
html 代码
<div class="images">
<a href="#"> <img id="default1" src="img/1.jpg" name="#content-target1" width="208" height="143" class="latest_img" /> </a>
<div id="content-target1">
<span class="tag_content">Design</span>
</div>
</div>
有什么想法吗?谢谢
I am trying this JS code in jquery capty plugin . However the plugin needs an image to works, like:
<img id="default1" src="img/1.jpg" name="#content-target1" width="208" height="143" class="latest_img" />
Well, when i add this image the JS below didn't works. Basically what i want is just click in span and show an alert message with the content.
$('.tag_content').live('click', function(event){
var span_val = $(this).parent().children("span").html();
alert(span_val);
});
html code
<div class="images">
<a href="#"> <img id="default1" src="img/1.jpg" name="#content-target1" width="208" height="143" class="latest_img" /> </a>
<div id="content-target1">
<span class="tag_content">Design</span>
</div>
</div>
Any idea ? thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面的代码似乎对我有用。你可以在jsFiddle上尝试一下: http://jsfiddle.net/fZSGt/4/
我也将
$(this).parent().children("span").html()
更改为$(this).html()
因为这似乎是不必要的你的代码。The following code seems to work for me. You can try it out on jsFiddle: http://jsfiddle.net/fZSGt/4/
I also changed
$(this).parent().children("span").html()
to$(this).html()
because it seems to be unnecessary for your code.