Question

I am trying to change the arrow on an :after pseudo element

my css

legend:after {
    content: url('/html/img/arrow-fieldset-up.png');
}

I am trying to change with

$('legend', selected_fieldset).attr('content','url(/html/img/arrow-fieldset-down.png)')
Was it helpful?

Solution

You cannot select the pseudo element with jQuery. Instead you can add a class to your CSS:

legend.selected:after {
    content: url('/html/img/arrow-fieldset-down.png');
}

then add this class when you want to change the content, for example when you click the legend:

$('legend').click(function() {
    $(this).addClass('selected');
})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top