Q:

accessing pseudo elements using $(this) keyword?

here is my code
var pollPercent = function() {
    $("#poll li").each(function(){
            var percent = $(this).attr("data-percent");
            var width = (percent / 100) * 1000;
            var el = $(this);
            $("head").append("<style>" + el + ":before {width: " + width + "px;}</style>");
    });
};

pollPercent();

so how can I point to each li and change its "before pseudo element"

A:

Try this:
var text = $('#poll').find('li').map(function (i) {
    var width = Math.round($(this).attr('data-percent') / 100 * 1000);
    return '#poll li:nth-child(' + (i+1) + ')::before { width: ' + width +  'px; }';
}).join('');

$(document.body).append('<style>' + text + '</style>');

