-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);
}
SuperKim
  • 35
  • 5

3 Answers3

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');
Mark Walters
  • 12,060
  • 6
  • 33
  • 48
  • 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? – SuperKim May 01 '14 at 13:07
1

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

Daan
  • 2,680
  • 20
  • 39
0

Yes you can by putting this in your script

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