Word change on hover using CSS, JavaScript, or jQuery?

change text on hover javascript
change text on hover css
change text on hover codepen
jquery hover
change text on hover jquery
onmouseover change color in javascript
change font size on mouseover javascript
how to change color of text when hover in css

I am currently working on a project where I would like a specific word (example: about) within a paragraph to change to a different word (example: abut) when you hover on the original word "about".

The purpose of creating a word change (when hovering over that word) would be for a web visitor to see the original [spelling of a] word from an old document when they hovered over a word, versus just reading the edited version.

I've played around a little with this in simple CSS (CodePen example here: https://codepen.io/LeahS/pen/LmvKZa), but would like to know the best way to create a word change as mentioned above. Is there a way with just CSS? Or is it better with jQuery or Javascript? I currently only know rough JavaScript and jQuery, but will learn both if it helps.

Appreciate your answers and insights, and thank you for taking time to comment.

Notes:

1: There would be multiple words that must be changed per paragraph, and multiple (more than 100+) paragraphs. If at all possible, I would NOT like to create unique CSS classes for each word...

2: I am/would like to use WordPress.

3: I am a beginner.

CodePen code:

<style>
.quote:hover .update, .quote .orig {
  display: none;
}
.quote:hover .orig {
  display: inline-block;
}
.quote .update {
  color: blue;
  font-weight: bold;
}
.quote .orig {
  font-style: italic;
}

</style>

<div>We went
<span class="quote">
<spell class="update">about</spell>
<spell class="orig">abut</spell>
</span>
our
<span class="quote">
<spell class="update">business</spell>
<spell class="orig">busness</spell>
</span>
.
</div>

You can use data attributes and CSS to display the two different words.

span[data-spell] {
  display: inline-block;
  border-bottom: 1px dotted gray;
  cursor: help;
}

span[data-spell]::before,
span[data-spell]::after {
  display: none;
}

span[data-spell]::before {
  content: attr(data-spell);
}

span[data-spell]::after {
  content: attr(data-original);
}

span[data-original]:not(:hover)::before,
span[data-spell]:hover::after {
  display: block;
}
<div class="quote">
  We went <span data-spell="about" data-original="abut"></span> our <span data-spell="business" data-original="busness"></span>.
</div>

Text Change on Hover Using CSS [VOICE TUTORIAL], [jQuery] How to change text color on hover using JavaScript? happen using JavaScript, and can't seem to get the CSS to have an effect while using this script. Word change on hover using CSS, JavaScript, or jQuery? 184. May 24, 2018, at 12:30 PM. Home CSS Word change on hover using CSS, JavaScript, or jQuery? LAST QUESTIONS.

You could wrap both elements in a span, and drive the hover off of that element, so that the hiding of the children does not affect the hover state.

.swappable .orig { display: none; }
.swappable:hover .orig { display: inline-block; }
.swappable:hover .update { display: none; }

.swappable { color: blue; }
<div class="quote">
  <div>We went
    <span class="swappable">
      <spell class="update">about</spell>
      <spell class="orig">abut</spell>
    </span> our
    <span class="swappable">
      <spell class="update">business</spell>
      <spell class="orig">busness</spell>
    </span> .
  </div>

[jQuery] How to change text color on hover using JavaScript , Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java  Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML.

I made a couple of changes to the html to make it work, and had both versions of the spelling be within the same span called "change". It's far from perfect but I suppose it's a start?

.changed:hover .update {
  display: none;
}
.changed:hover .orig {
  display: inline-block;
}
.quote .update {
  color: blue;
  font-weight: bold;
}
.quote .orig {
  font-style: italic;
  display:none;
}
.changed {
cursor:pointer
}
<div class="quote">
<div>We went
<span class="changed"><spell class="update">about</spell><spell class="orig">abut</spell></span>
our
<span class="changed"><spell class="update">business</spell><spell class="orig">busness</spell></span>
.
</div>

CSS :hover Selector, The first variable, target, defines the CSS selector that jQuery will use to In other words, this class represents a kind of hover style so you can change the  In this tutorial, learn how to change div background color on hover using CSS or jQuery. The background color change on hover to show div content in an attractive way.. You have options to create background color on hover using CSS and jQuery.

Showing the other word with plain, vanilla CSS, based on your provided HTML code is as simple as:

spell.update:hover + spell.orig, spell.orig:hover {
 display:inline-block;
}

If you want to hide the updated spelling when they're looking at the original, you might find it helpful to enclose both in a span, so you can do the following:

span.spelling-container:hover>.orig {
 display:inline-block;
}
span.spelling-container:hover>.update {
 display:none;
}

JavaScript: The Missing Manual: The Missing Manual, Hover states are easy, but what if you want to apply a hover state to every element Let's use an opacity change as an example: If it's mission critical, use JavaScript to detect mouseenter events on them and apply/remove class names. Let me not use words like amazing, love or aaaaaawsaaaam* :hover{ so much  I would like the navigation's text color to turn white on hover, but I don't know how to make this happen using JavaScript, and can't seem to get the CSS to have an effect while using this script

Hover on "Everything But", How to Change the Style of <a> Tag Title Attribute ? How to create responsive image gallery using HTML, CSS, jQuery and Bootstrap? Create a Mobile Toggle Navigation Menu using HTML, CSS and JavaScript · How to We can apply CSS to display div element on hover a tag by using an adjacent sibling selector. The hover () method specifies two functions to run when the mouse pointer hovers over the selected elements. This method triggers both the mouseenter and mouseleave events. Note: If only one function is specified, it will be run for both the mouseenter and mouseleave events.

Display div element on hovering over <a> tag using CSS , How to change image on hover with CSS · Previous Page Next Page. Advertisements. Font Awesome Icon Classes  Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML.

How to Animate Text Color on Mouse Hover Using CSS, Get the value of a computed style property for the first element in the set of matched elements or set Also, jQuery can equally interpret the CSS and DOM formatting of multiple-word properties. <script src="https://code.jquery.com/​jquery-3.4.1.js"></script> Change the color of any paragraph to red on mouseover event. How to Change Image on li Hover Using HTML,CSS and JQuery. If you want to Change Image on li Hover using jquery, you can find the answer in the example given below. Now, suppose your company has four members and you want to display the designation and image of them.

Comments
  • Well, just glancing at your css .quote:hover is defining a rule when the user hovers over the quote, not necessarily the update or orig. The only issue with performing this with css only, is as soon as you hover and hide the original, hiding causes the hover to end, so it will show again, and then hide again, and show again, and ...