JQuery选择伪元素:after [英] JQuery select pseudo-element :after

查看:3544
本文介绍了JQuery选择伪元素:after的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想选择伪元素:在之后

这是我的css:

show-more:after
{
    content : (" > ");
}

JQuery code

$(function(){
    $('.show-more:after').click(function() {
        alert("Yes");
    }); 
});


推荐答案

你可以绑定到他们的父元素,但这不是伪元素可能:那些根本不是DOM的一部分,所以你不能将任何事件直接绑定到它们。

You can bind to their parent elements but this is not possible with pseudo-elements: those are not part of the DOM at all so you can't bind any events directly to them.

抱歉和问候,

网址: http://stackoverflow.com/ questions / 7478336 / only-detect-click-event-on-pseudo-element

编辑:

实际上是可能的:抱歉。

Actually is possible: sorry.

这里是JSFiddle的URL :
演示链接

Here URL of a JSFiddle: Demo link

这篇关于JQuery选择伪元素:after的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆