Show the text of a link when it is selected using the tab key in a JavaScript event

Snippet:

<a href="#about"> About <abbr title="The Little Taco Shop">About LTS</abbr></a>

Show the text "About LTS" when the tab key is pressed on the keyboard.

Answer №1

When the link is in focus, the description tag becomes visible. It will disappear once the focus is removed.

Is this what you were looking for?

document.addEventListener("keydown", (event)=> {
    if (event.keyCode === 9) {  
      document.getElementById("focusBtn").addEventListener('focus', (event) => {
        document.getElementById("alt").style.display = "inline-block";
      });
      document.getElementById("focusBtn").addEventListener('focusout', (event) => {
        document.getElementById("alt").style.display = "none";
      });   
    }
});
#alt{
  display:none;
  margin-left:10px;
}
<a href="#about" id="focusBtn" > About <abbr id="alt" title="The Little Taco Shop">About LTS</abbr></a>

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

The initial result from reactQuery may start off as undefined, but eventually it will provide the data as

Currently, I am working on fetching data using reactQuery and storing the response in a variable when clicked. const { data: response, refetch } = useQuery({ queryKey: ['get-response'], queryFn: async() => { return await Axios ...

Nested flexbox causing Firefox to malfunction in handling overflow-y

I successfully created a layout using CSS3 flexbox that spans 100% width and height. This layout functions properly on IE11, and possibly on IE10 when emulating IE11. Unfortunately, I encountered an issue with Firefox (35.0.1) where the overflow-y propert ...

The functionality of "Body Onload" for sending "ScrollHeight" is malfunctioning in Chrome and Safari

I came across an issue where the iframe_resize function in my code was not working as expected. After investigating further, I realized that the problem did not lie with the function itself. So, I decided to post a new question. Within my index.html file ...

The presence of certain characters is leading to problems in the console

Similar Question: Escaping a String for JavaScript Usage in PHP? The characters in my text are causing errors. When I input special characters such as: !\"$%^&()-=\'.,:;/?#~/\\>< An error saying "Syntax error ...

Present a two-column layout using row formatting in Bootstrap with Angular

In my component file, I have an arrayData containing 4 datas, and I am trying to display them in two columns across two rows. <div class="row"> <div class="col-md-6" *ngFor="let cat of myArrayData; let index=index"> <div clas ...

Issue with the Edit feature causing conflicts with the local storage and generating error messages

There seems to be an issue with my edit function that is causing it to override the local storage when I attempt to save and interfering with my delete function as well. I have searched through similar posts for a solution but have not been able to pinpo ...

Ensure your mobile device is age 13 or over before proceeding

I am developing a project with Next js. Here, I want to render a component if it is a mobile device. However, if I use the isMobileDevice value in jsx, I get the errors below. import useTranslation from "next-translate/useTranslation"; import isM ...

The error message "window is not defined" occurs when the external file 'signalr.min.js' is included

Updates OpenTest --version 1.2.2 ChromeDriver 85.0.4183.87 Whenever I attempt to add the necessary external javascript files, it results in the following errors: Caused by: java.lang.RuntimeException: Failed to evaluate JavaScript code at line number 1. ...

What is the best way to incorporate a description box for each city on the svg map that appears when you hover your mouse over it?

I am looking to display detailed descriptions for each city in the same consistent location on my map. With multiple pieces of information to include for each city, I want to ensure that the description box is positioned at the bottom of the map. Can any ...

Preventing v-stepper-step header click in Vuetify.js when form is invalid

I'm using Vuetify's v-stepper component. What I'm trying to achieve is: When a user clicks on a stepper step in the header, I want to block the click event if the active form is not valid. I have been able to accomplish this by attaching ...

Issues encountered during transition of HTML document to XML through VBA web scraping when attempting to click on a button

I am currently working on a project that involves using an MSHTML.HTMLDocument code to extract data from a specific webpage. The process involves the following steps: Opening the webpage at "https://www.ksestocks.com/HistoryHighLow" Entering a value ...

Incorporating CSS styling to specific elements

I am facing an issue with a CSS rule that looks like this: div#tabstrip.tabstrip-vertical.k-widget.k-header.k-tabstrip div#tabstrip-4.k-content.k-state-active{ background-image: url("http://wwww.example.com/logo2.png") !important; background-posit ...

Issue with installing vscode-ripgrep during VSCode build/run process

After attempting to build and run VSCode on my Ubuntu 17.10 by following the instructions from this guide: https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run, I encountered an issue when installing dependencies using yarn. The error m ...

Interactive chat feature with live updates utilizing jQuery's $.Ajax feature for desktop users

I came across a script for real-time chat using $.ajax jQuery, but it only refreshes my messages. Here's an example scenario: I type: Hello to You, and I see this message refreshed. You reply: Hey, in order to see your message, I have to manually refr ...

Is it possible to control the visibility of content in HTML based on the current time of day?

Is it possible to display specific parts (divs) on a local site during specific times of the day? If so, how can this be implemented? Thank you. Here is an example of a simple page: <!DOCTYPE html> <html lang="en> <head> <title&g ...

The onmouseout event is triggered when the mouse leaves a table row or cell

My image has an onmouseover function that displays a table with options over the image (dimming the image). The table also has an onmouseout function to hide the table and show the image again. The issue I'm facing is that when the mouse moves between ...

How to troubleshoot syntax errors when using the delete function in Three.js within Eclipse

When using the Javascript Library Three.js, it is important to note that the delete keyword can be used as an object property. While this is valid under ECMAScript 5 standards, Eclipse currently only supports ECMA 3. As stated in the Mozilla reference, re ...

Getting rid of a particular jQuery animation

I have been searching all over the site, but my limited knowledge prevented me from finding the right solution. I've been working on my website and had previously used a different theme. I have made several changes and am quite happy with it overall. ...

Using Angular to bind the ngModel to a variable's object property

In my application, I am working with a user object that looks like this: let user = {name: "John", dob:"1995-10-15", metadata: {}} The metadata property of the user object is initially empty. I want to add a new property to the metadata object based on u ...

Retrieve information in JSON structure

Currently, I am making a GET http request to the Google Civic's API. The purpose is to provide an address and in return receive information about members of the U.S. government based on the location of the provided address. // In the code below, the ...