Hovering over text with a class changes color of all text with same class - jQuery
-
Hi @Armin-Unruh , hope you're well :smile:
I'm trying to write some jQuery so that whenever i hover over a class 'colorbutton' it chnages the color of all text with the same class on the page.
I found a fiddle which does basically this (ignore the two different things i just want to do it to one class) but I cant figure out how to adapt it to work with Lay as i'm not very experienced with javascript - trying to learn.
function highlightAllOnMouseover(className){
$(className).mouseover(function() {
$(className).css("opacity", 0.4);
$(className).css("opacity", 1);
}).mouseleave(function() {
$(className).css("opacity", 0.4);
});
}
highlightAllOnMouseover(".thing1");Any ideas for this?
Heres the fiddle
http://jsfiddle.net/aZXRM/ -
Hi @Armin-Unruh , hope you're well :smile:
I'm trying to write some jQuery so that whenever i hover over a class 'colorbutton' it chnages the color of all text with the same class on the page.
I found a fiddle which does basically this (ignore the two different things i just want to do it to one class) but I cant figure out how to adapt it to work with Lay as i'm not very experienced with javascript - trying to learn.
function highlightAllOnMouseover(className){
$(className).mouseover(function() {
$(className).css("opacity", 0.4);
$(className).css("opacity", 1);
}).mouseleave(function() {
$(className).css("opacity", 0.4);
});
}
highlightAllOnMouseover(".thing1");Any ideas for this?
Heres the fiddle
http://jsfiddle.net/aZXRM/@Armin-Unruh Actually ive got this code which seems to be right but perhaps not written properly?
<script>
jQuery(document).ready(function(){
jQuery('.text1 h1').hover(
function() {jQuery('.text1 h1').css({"color":"blue"});
},function() {jQuery('.text1 h1').removeAttr('style');});
</script>