Jquery 如何在after伪元素中应用url路径?

Jquery 如何在after伪元素中应用url路径?,jquery,html,css,Jquery,Html,Css,我有以下css #custom-module .moduletable:nth-child(2) h3 { background: url(../images/icon-news.jpg)no-repeat center left; position: relative; } #custom-module .moduletable:nth-child(2) h3:after{ background: url(../images/icon-all-news.jpg) no-

我有以下css

#custom-module .moduletable:nth-child(2) h3 {
    background: url(../images/icon-news.jpg)no-repeat center left;
    position: relative;
}
#custom-module .moduletable:nth-child(2) h3:after{
    background: url(../images/icon-all-news.jpg) no-repeat right center;
    content: url(www.google.com);
    position: absolute;
    width: 22px;
    height: 9px;
    top: 10px;
    right: 0;
}
如何使背景后的
h3:afterbackground
可点击


请注意,我无法将
h3标记
a标记



如果不可能,我如何使用jquery分配此a href?

不可能使用CSS,jquery解决方案将如下所示:

var $link = $('<a>',{
    class: 'all-news-link',
    href: 'http://google.com'
});

$('#custom-module .moduletable:nth-child(2) h3').append($link);

结果如何?正在添加元素吗?当你点击时会发生什么?@NavinRauniyar它看起来怎么样?您可以右键单击它并选择“检查元素”选项,看看那里是否一切正常吗?@NavinRauniyar您确定页面中有一个元素与选择器
#自定义模块匹配。模块表:第n个子(2)h3
?你能发布你的HTML标记吗,最好是用小提琴?还可以尝试将display:inline块添加到CSSYE,您可以通过这种方式构建html节点,尝试将其添加到代码中,以查看是否匹配任何元素
alert($('#custom module.moduletable:nth child(2)h3').length)
您也正在将代码放在
$(文档)中。就绪(函数(){})
?@NavinRauniyar,它正在被追加和包装,但是小提琴没有样式,因此您看不到它,请检查这一个
#custom-module .moduletable:nth-child(2) h3 .all-news-link{
    background: url(../images/icon-all-news.jpg) no-repeat right center;
    position: absolute;
    width: 22px;
    height: 9px;
    top: 10px;
    right: 0;
}