-1

Hey this is super simple, I hope...

Can I use jQuery or JavaScript to change this:

.tint:hover:before {  
    background: rgba(0,0,255, 0.5);
}

To this:

.tint:hover:before {  
    background: rgba(255,0,0, 0.5);
}
0

3 Answers 3

1

No, Pseudo-elements are not part of the DOM (Document Object Model), so they can't be manipulated by jQuery or Javascript.

Sign up to request clarification or add additional context in comments.

Comments

1

Why not have a separate class

.newTint:hover:before {
   background: rgba(255,0,0, 0.5);
}

Then use jQuery to switch the classes

$('#myField').removeClass('tint').addClass('newTint');

1 Comment

Because the value could be "255,255,255, 0.5", "0,0,0, 0.5", or any thing in-between if that makes sense. Perhaps I could create the class first?
0

Yes you can by putting this in your script

$(document).ready(function(){
$('.tint:hover:before').css('background',' rgba(255,0,0, 0.5)');
});

3 Comments

This doesn't seem to work.
thats weird, when I try it it works
can you give me a link, this page here:

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.