im jQueryでセレクターの前に固定された位置をアニメーション化しようとしています。jQuery で :before セレクターを呼び出してアニメーション化する方法 クラスなどを呼び出すことで他のメソッドを知っています。しかし、jQuery でのみ実行したいのです。
html
<div id="main"></div>
CSS
#main {
width:200px;
height:300px;
background:#000;
}
#main:before {
content:'im before';
position:fixed;
left:0px;
top:0px;
width:40px;
height:40px;
background:blue
}
js
$("#main").hover(function () {
$(this).animate({
"margin-left": "40px"
});
$("#main:before").animate({
"margin-left": "40px"
});
}, function () {
$(this).animate({
"margin-left": "0px"
});
$("#main:before").animate({
"margin-left": "0px"
});
});
注:プラグインなしで解決策を教えてください