문제

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)')
도움이 되었습니까?

해결책

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');
})
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top