我有以下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:after background
点击?
请注意我无法用h3 tag
a tag
如果不可能,我如何使用jquery分配这个href?
答案 0 :(得分:2)
使用CSS不可能,jQuery解决方案看起来像这样:
var $link = $('<a>',{
class: 'all-news-link',
href: 'http://google.com'
});
$('#custom-module .moduletable:nth-child(2) h3').append($link);
然后你将CSS更改为:
#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;
}