?
Solved

How to press and button and change another class

Posted on 2016-08-26
2
Medium Priority
?
58 Views
Last Modified: 2016-08-26
Hi, experts

I would like to learn how to change the background color of another class ( .fullscreen-bg ) when hover on a button ( .btn ).

            <div class="hero-text-box">
                <a class="btn" href="#"><img src="img/image.png" alt="cta" class="cta"></a>
            </div>
            <div class="fullscreen-bg">
             <video loop muted autoplay poster="img/videoframe.jpg" class="fullscreen-bg__video">
                    <source src="video/042016.mp4" type="video/mp4">
                </video>
            </div>

Open in new window


.btn:hover,
.btn:active {
    background-color: #cf6d17;
}

Open in new window


.fullscreen-bg {
  opacity: 0.4;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  z-index: -100;
}

Open in new window

0
Comment
Question by:mingchih
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 44

Accepted Solution

by:
zephyr_hex (Megan) earned 2000 total points
ID: 41772474
You can do this with jQuery.  Here is a Fiddle Demo.

HTML
<input type="button" class="btn" value="Hover Me">
<div class="fullscreen-bg">
  Hello World
</div>

Open in new window


jQuery
$('.btn').hover(
  function() {
    $('.fullscreen-bg').css({
      "background-color": "red"
    });
  },

  function() {
    $('.fullscreen-bg').css({
      "background-color": "transparent"
    });
  }
);

Open in new window

0
 

Author Closing Comment

by:mingchih
ID: 41772493
thanks!!
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question