I want to select :after elements .how to do that using jquery ?
You can't, generated pseudo-elements don't exist in the DOM (yet, sadly).
We can prove this like so:
CSS:
#foo:before {
content: '[Before]'
}
#foo:after {
content: '[After]'
}
HTML:
<body><div id="foo">Foo</div></body>
JavaScript:
(function() {
var msgs = [];
var child;
var div;
for (child = document.body.firstChild;
child;
child = child.nextSibling) {
if (child.id) {
msgs.push("Child " + child.nodeName + "#" + child.id);
}
else {
msgs.push("Child " + child.nodeName);
}
}
div = document.createElement('div');
div.innerHTML = msgs.join("<br>");
document.body.appendChild(div);
})();
The page resulting from the above (if we assume the script
element is added to body
at the end) is:
[Before]Foo[After]
Child DIV#foo
Child SCRIPT
Live Copy | Source
As you can see, the generated pseudo-elements are just not present at all as far as the DOM is concerned.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…