Is it possible to completely change the displayed text using the :hover effect?

I have been unable to find any other platform where I can seek advice on this particular issue. I am currently working on editing the CSS of a website for a friend who wants the title text to change when hovered over. However, despite my efforts, I have struggled to make the :hover function work for the title. I am torn between completely recoding it, considering it was part of a predefined theme she found, or seeking guidance on how to achieve the desired effect.

The specific request is for the ability to hover over the title, "Veoleth Dathgir," and have it transform into a different word. Unfortunately, my attempts so far have not yielded the desired outcome.

It's worth noting that I do not possess professional experience in this field; my knowledge comes from years of self-taught hobbyist practice. As a learning opportunity, what steps should I take to implement this change? Despite scouring various resources like Google and W3Schools for an hour or two, I have yet to make any significant progress.

You can access the full page code here, with relevant lines included below:

    .title {
  font-family:'apple chancery',uppercase; /*title font*/
  font-size:30px;
  padding-top:90px;
  text-shadow:0 0 10px rgba(0,0,0,.3);
}

.subheader {
  margin-top:10px;
}

.header {
  width:550px;
  height:200px;
  -webkit-transition:ease-in-out .5s;
  -moz-transition:ease-in-out .5s;
  -o-transition:ease-in-out .5s;
  transition:ease-in-out .5s;
  text-align:center;
  letter-spacing:1px;
  color:#271717;
  border-bottom:solid #381F1F 20px;
  background-color:#423535;
  background-image:url();
  background-position:center;
  background-size:100% auto;
}

.header:hover {
  letter-spacing:3px;
  text-shadow:0 0 30px rgba(255,255,255,.6);
}

In addition, here are some snippets from the page:

<div class="header">
<div class="title">Veoleth Dathgir</div>
<div class="subheader">Spurned Ghosts</div>
</div>

Answer №1

Sure, using jQuery would be the best approach for that. To incorporate jQuery into your site, you can add the following code snippet at the bottom of your HTML body element:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

Next, assign an ID to the title element like so:

<div  id="thisTitle" class="title">Veoleth Dathgir</div>

For the jQuery functionality, insert the code below at the end of your body element in the HTML file:

<script>
// Change text on mouseover
$('#thisTitle').mouseover(function(){
  $(this).text('anything you want');
});
// Revert text on mouseout
$('#thisTitle').mouseout(function(){
  $(this).text('Veoleth Dathgir');
}); 
</script>

View a working example here. You can use the "export" option located in the lower right corner if needed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Arranging my pictures through CSS styling

Upon examining my webpage, I've noticed that the images are not properly aligned. My goal is to have the icons perfectly lined up; however, it seems there's a discrepancy depending on another cell, based on the size of the container where the tim ...

Unsupported MIME format

I'm encountering an issue where my stylesheet is not applying to my handlebars. It was working fine yesterday, but today I'm seeing a MIME error and I'm unsure of the reason behind it. Any assistance would be greatly appreciated. Server Cod ...

Inherit margins from child elements with fixed positions

Below is a very basic code example to consider: <div id="parent"> <div id="child"> Test it </div> </div> This code snippet includes the following CSS styles: #parent{ position:relative; margin-left:200px; color:#FFF; } #chi ...

Tips for merging two text boxes in a form with CSS

Is it possible to combine two text boxes in a form using CSS, similar to the design on Tumblr's login page at ? If CSS is not the solution, what alternative methods can be used? Any assistance would be greatly appreciated. I am aiming to enhance the ...

Achieve the effect of bringing the div and its contents to the top when hovered over, all while keeping

I have designed a popup that includes multiple boxes. I want the width of the box to expand and be visible over all content on the webpage when a user hovers over any ".deviceboxes". I tried using ".deviceboxes:hover" which worked fine for the first box in ...

Organizing MySQL query results in PHP by displaying them in three columns with multiple rows

I am looking to feature a gallery section on my website. The layout I have in mind consists of 3 slides, with each slide containing 3 columns. The first column should be col-md-6, while the second and third columns should be col-md-3 each. Specifically, I ...

I am encountering a recurring issue with my code where it keeps showing a 'not defined

Previously, this code was working fine, but now it has stopped functioning and I can't figure out why. I've tried reorganizing things and changing values, but I keep encountering the same error. If someone could point out where to add a line, tha ...

Create a unique margin using CSS only that will appear at the bottom of a flex-row container that scrolls

I'm trying to create a horizontal scroller with margins between each item and consistent margins at both ends. However, I'm noticing that the margin at the end of the container seems to be disappearing somehow. Is there a way to maintain the mar ...

Creating a dynamic background image for the ul/li div element

As a newcomer to website development, I am currently exploring how to dynamically set images in the ul/li elements within a div. Below is a snippet of the HTML code I have been working on: <div class="results"> <ul class="row"> < ...

What could be causing the next button to not display the content on the following page when clicked?

Hello, I'm new to programming and I'm working on creating a complaint page using Bootstrap, CSS, and JavaScript. I encountered an issue when trying to hide the content of the next page using the following CSS code: .needs-validation fieldset:not( ...

What are some effective ways to analyze jQuery and JavaScript using web development tools?

I'm struggling to use web development tools to inspect the JavaScript on websites. It's challenging to identify which parts of a site are utilizing JS, unlike CSS or HTML where it's more visibly defined. Even when I attempt to delete some J ...

The picture tag in HTML5 is failing to be responsive when used with Bootstrap

I'm experimenting with the html5 <picture> tag to set different images. I placed the 2 pictures within a bootstrap grid, allowing them to be responsive until the breakpoint 768px, where the image changes. However, when I decrease the browser si ...

Creating a hanging indent for bullets in CSS by using em units

I am trying to create hanging indents for 'bullets' by indenting wrapped lines after the initial prefix (e.g. "1. " or "1a). " Take a look at this example of HTML: <html><body> <div style="text-indent: -3em; padding-left: 3em;"&g ...

Tips for ensuring smooth rendering of big fonts in Chrome on OSX

On my Macbook Pro running Mojave, I noticed that regular fonts appear normal, but large fonts look jagged in Chrome (unlike Safari or Firefox). You can see an example on CodePen .large { font-size: 300px; font-weight: bold; } Chrome https://i.sstat ...

The correct rendering of React css only occurs after refreshing the IDE

Can anyone assist me with understanding this unexpected behavior in my CSS? I'm struggling to figure out why it's happening and how to correct the CSS imports. In my react app, there is a single component that imports a stylesheet from a separat ...

Isolating the controls bar from the video content area within JWPlayer

Currently, I am utilizing JWPlayer for my video playback needs. I am curious if there is a method to separate the controls bar from the video content, similar to the design showcased in this link: https://i.sstatic.net/bZUA9.png Alternatively, are there a ...

Anticipated a JavaScript module script, but the server returned a MIME type of text/html as well as text/css. No frameworks used, just pure JavaScript

I have been attempting to implement the color-calendar plugin by following their tutorial closely. I have replicated the code from both the DEMO and documentation, shown below: // js/calendar.js import Calendar from '../node_modules/color-calendar&ap ...

Designing a custom style for a select box using CSS and HTML

Recently, someone assisted me in removing the outline of my select box in my debut bootstrap-django project. Now, I am seeking your guidance on altering the border color property of the options box itself from blue to yellow. Strangely, when the select box ...

Incorporate a course within the conditional statement

Currently, I'm working on the development of an input site and one of my goals is to highlight empty fields. My plan is to check if a field is empty using an if statement and then apply a specific class that will serve this purpose. This is the JavaS ...

Concealing a column within an Angular Material table

I'm currently faced with a challenge involving an Angular Material table containing numerous columns. My goal is to selectively hide certain columns based on specific CSS media queries. This is the code snippet I have experimented with so far: HTML: ...