When hovering over a select option, a description and clickable link will be displayed

I need to display a description with a clickable link when hovering over any option in the select tag.

<div class="col-lg-4">
  <div class="form-group">
    <label class="form-label">Goal</label>
    <select name="semiTaskType" class="form-select" id="semiTaskType">
      <option>Select Option</option>
      <option value='regression'>Soft Sensor</option>
      <option value='classification'>Contributory Factors</option>
      <option value='forecasting'>Prediction</option>
    </select>
  </div>
</div>

Is there any way to make this happen?

Answer №1

If you'd like to utilize the select/option tag, keep in mind that customization of the default drop-down list is limited.

To create a custom drop-down list, consider using the Bootstrap element dropdown or coding your own design from scratch.

For an example of a custom drop-down list, check out this link: https://codepen.io/Sinorielle/pen/jOGKYaP

Here's an HTML snippet:

<div class="col-lg-4">
    <div class="form-group">
        <label class="form-label">Goal</label>
        <div name="semiTaskType" class="form-select customDropDownList" id="semiTaskType">
          <div class="selectedOption">Select Option ▼</div>
          <ul class="listContainer">
            <li value='regression'>
              <p>Soft Sensor</p>
              <p class="description">
                Description
                <a href="#">The link of death</a>
              </p>
            </li>
            <li value='classification'>
              <p>Contributory Factors</p>
              <p class="description">
                Description
                <a href="#">The link of death</a>
              </p>
            </li>
            <li value='forecasting'>
              <p>Prediction</p>
              <p class="description">
                Description
                <a href="#">The link of death</a>
              </p>
            </li>          
            <li value='forecasting2'>
              <p>Title</p>
              <p class="description">
                Description
                <a href="#">The link of death</a>
              </p>
            </li>
          </ul>
        </div>
    </div>
</div>

CSS styling:

.customDropDownList{
  display: inline-block;
  position: relative;
}

.customDropDownList:hover .listContainer{
  display: block;
}
.selectedOption{
  padding: 5px;
  border: 1px solid black;
  border-radius: 5px;
  background: white;
}
.listContainer {
  display: none;
  position: absolute;
  border: 1px solid black;
  padding: 0;
  margin: 0;
  border-radius: 5px;
  list-style: none;
  z-index: -10;
}
li {
  
  padding: 5px;
}
li:hover {
  cursor: pointer;  
  background: grey;
}
p {
  margin: unset;
}
.description {
  display: none;
}
li:hover .description {
  display: block;
}

Answer №2

If you need to add tooltips to your website, Bootstrap's tooltip feature is a great option. Here are a couple of examples:

 <button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="right" title="Tooltip on right">
  Tooltip on right
</button>

Another example can be seen below:


<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">
  Tooltip with HTML
</button>

If you want more in-depth information on how to use tooltips with Bootstrap, refer to the official Bootstrap documentation.

I hope this helps!

Answer №3

Here's a helpful tip: consider utilizing the title attribute within the option tag.

<option title="Your description">Select Option</option>

I believe implementing this suggestion will be beneficial.

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

Update the image source within a CSS element

I'm facing an issue with changing the source image of an Element. The situation is that I have a customized CSS script and I need to modify a logo image. Below, you can find the source code: https://i.stack.imgur.com/8HLCE.png The problem lies in at ...

"Effortless alignment: Centralizing CSS styling across the entire

I need help placing a loading spinner in the center of my screen, ensuring it works on both mobile and desktop devices. Here is my current CSS code: .spinner { width: 100px; height: 100px; position:absolute; top: 50%; left: 50%; margin: 100px ...

Saving resources with a promise in Angular

I am facing a challenge while trying to handle a promise from the angular $resource save function. According to the documentation, I should be able to access the raw $http promise by using the $promise property on the returned object. Here is an example: ...

Utilize the HTTP.get function to serve files in the img src attribute

I am facing an issue where my file can only be accessed if I include an x-authentication token in the header of the "GET" http request. Unfortunately, using a cookie is not an option in this case. This means I cannot simply call for the file by its URL in ...

What is the method to determine the overall size of a webpage using the Google PageSpeed API?

"analytics": { "cssResponseBytes": "333 kB", "htmlResponseBytes": "269 kB", "imageResponseBytes": "3.35 MB", "javascriptResponseBytes": "2.29 MB", "numberCssResources": 2, "numberHosts": 80, "numberJsResources": 72, "numberR ...

What is the best way to accomplish this task with ajax?

Hello, I'm new to using ajax and jquery. Could someone please explain how I can achieve this without page refresh? Here is my PHP code: <div class="recentwork"> <div class="imgholderfloat"> <?php include 'process/connect.php' ...

Determine if the same origin policy is in effect

Is there a method to determine if the same origin policy is applicable to a URL before attempting to use ajax methods? Below is an example of what I currently have: function testSameOrigin(url) { var loc = window.location, a = document.create ...

Multiple Ajax requests being made

Below is the code snippet in question: <div id="assignWindow" style="display:none; width:500px"> Invoice # <input id="invoiceNumber" name="invoiceNumber" /><br /> Amount: <input id=" ...

What are some ways to conceal methods within a class so that they are not accessible outside of the constructor

I am a newcomer to classes and I have written the following code: class BoardTypeResponse { created_on: string; name: string; threads: string[]; updated_on: string; _id: string; delete_password: string; loading: BoardLoadingType; error: Bo ...

Why does the div inside the tbody element get automatically shifted outside of the tbody during rendering?

Below is a snippet of my code: <body> <table> <tbody> <div>test</div> </tbody> </table> </body> Upon executing the code mentioned above, it transformed automatically in ...

jade, express, as well as findings from mysql

My goal is to display the results of an SQL query in Jade, which pulls data from a table of banners. Each banner has a unique id and falls under one of three types. Here is my current code : express : connection.query("SELECT * FROM banner_idx ORDER BY ...

Encountering a mixed content error in Internet Explorer 8 due to the Nivo slider jQuery?

I am encountering an issue with the Nivo jQuery slider on my HTTPS website, as it appears to be generating a mixed content error in Internet Explorer 8. Despite posting on the Dev7 Studios forum and conducting extensive research on the IE 8 mixed content ...

Positioning the comments box on Facebook platform allows users to

Need assistance, I recently integrated the Facebook comments box into my Arabic website, but I am facing an issue where the position of the box keeps moving to the left. Here is an example of my website: Could someone please suggest a solution to fix the ...

Using React.js to select and change the color of an element

I'm developing a movie theater app, in which I am building a feature to select seats in the cinema hall and add them to the cart. Here is the function that displays the cinema hall: export default function CinemaHall(props) { const row = props.row ...

What is the best way to access an Ajax response outside of its function using JQuery?

Just starting out with JQuery and wondering how to utilize the Ajax response ( HTTP GET ) outside of the function in my code snippet below: $.ajax ({ type: "GET", url: "/api", success: success, error: error ...

Changing from Basic to JavaScript?

Good evening, I am looking to convert this example code from Basic to JavaScript. Since JavaScript does not support the "Go To" command, I would appreciate it if you could help me with the translation. Thank you in advance. 10 x = 1666.66 20 y = 1.007897 ...

Launch a new tab within the parent window, passing on variables from the parent window

Currently, I have a button that opens a new window in a new tab by using window.open("newpage.html"). In the child window, I use childVar = window.opener.parentGlobalVar to access global variables from the parent window. Now, I have been requested to open ...

Utilizing dynamically assigned ng directives in my unique custom directive

I'm in the process of creating a customized table element that looks like this: <datatable items='tableItems' columns='columnsConfig' /> Here, 'tableItems' represents my array of items and 'columnsConfig&apos ...

Sorting of tables does not function properly following an ajax request

I built a table that utilizes an AJAX response triggered by selecting a date from a drop-down menu. <!--datepicker--> <div class="col-md-4"> <input type="text" name="date_po_month_picker" id="date_po_month_picker" class ...

What is the correct approach for detecting object collisions in Phaser 3?

Hey everyone, I'm facing a problem and could use some assistance. Currently, I am trying to detect when two containers collide in my project. However, the issue is that the collision is being detected before the objects even start moving on screen. It ...