?
Solved

How to press and button and change another class

Posted on 2016-08-26
2
Medium Priority
?
63 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:Brian Lin
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:Brian Lin
ID: 41772493
thanks!!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses four methods for overlaying images in a container on a web page
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

757 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