Retrieve the text from the thumbnail image's "alt" or "title" attribute and utilize it as a signature for the enlarged popup photograph

Is it possible to achieve this? I have a thumbnail image with both alt and title attributes, and when the image is hovered over or clicked on, I want an enlarged image to pop up. Additionally, I would like the alt or title of the image to appear as a signature at the bottom of the image's border. I have tried using the CSS popup image viewer trick, but I'm wondering if there is another way to accomplish this. I believe it has something to do with this statement:

a:after { content: " (" attr(href) ")"; }

I attempted to use the content: attr(title); statement in the following way:

img.thumb:active img.thumb:after { content: attr(title); font-weight: bold; margin: 10px 400px 20px 400px; }

As a newbie in web design, I have been searching for inspiration to make this work but haven't had any luck so far.

Any help would be greatly appreciated. Thanks!

Answer №1

If you want to extract information from an image, using jQuery is the way to go. You can retrieve the alt tag or any other attribute with this simple line of code:

var altText = $('img').attr('alt');

To ensure you are targeting the correct image, it's a good idea to assign an id to it as well.

Once you have captured the desired information, you can add it to the signature section like this:

$('#signature').append(altText);

If you need more detailed instructions, feel free to leave a comment for further assistance.

While the aforementioned method works in theory, there are also various lightbox plugins available that offer similar functionality. Have you considered trying out colorbox?

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 font style of the navigation bar

Hey there! I recently downloaded a template from this website: . However, I'm facing an issue with the nav bar displaying strange fonts when using Vietnamese letters. For example, "Nước" shows up as all uppercase and the letters "uo" are shortened. ...

Issues with the use of overflow:hidden

I need to create 5 divs aligned horizontally next to each other, spanning the width and height of the window. Each div should occupy 20% of the window width, and any overflow content should be hidden. Below is the CSS code for two of the divs: #container1 ...

I prefer to prevent the page from refreshing once the PHP code is executed

<?php $sendTo = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="45203d242835292005203d24283529206b2b29">[email protected]</a>"; //Receiver mail $name = ""; //Sender's Name $email = ""; //Sender' ...

Concealing a div element if the value is null

Here's my code: if ($image1 !=='') { //Insert div here } However, I'm encountering parse errors when I try to place the div within the curly brackets. Is there a specific syntax or format that I am missing...? ...

Using AngularJS to incorporate personalized font icons

Looking to create a custom font icon library similar to "Font Awesome" for my AngularJS project, as using fonts instead of images is more versatile across devices. Is there a way to achieve this? I have generated a font in .ttf and .svg formats with my ...

Incorporating a bottom line or border within the input field with a specified width

I have been struggling with styling an input field. I added a 1px solid #000 border around it, but now I need to include a thicker black line within the input itself. I tried using border-bottom: 5px solid #000, but that just created a border at the bottom ...

Ways to rotate just the border without rotating the icon through CSS

I need help with rotating only the border 135 deg on hover, without affecting the icon. Below is the code I am using. Any assistance would be greatly appreciated. Thank you! My html: ` <div class="container-fluid details-section"> ...

Can we switch out the jQuery background color for a background image instead?

I received a recommendation from a friend that involves utilizing this jquery code: .css({ backgroundColor: '#ddd' }) However, I prefer to use a background image instead. How can I modify the jquery code to achieve this? I am looking to implem ...

Why does my jQuery IMG center script not work in Chrome and Safari, but it works perfectly in IE?

I am experiencing an issue with centering the thumbnails of products on my e-commerce website. Despite successful centering in IE, FF, and Opera, Chrome and Safari are not aligning the thumbnails properly – they remain at the top of the div instead of be ...

Utilizing Modal Popups in ASP.NET MVC for Button Clicks Embedded within a jQuery Datatable

For my current project, I am working on a page that includes a table with data. However, I want to implement a Bootstrap modal to display unique message content in the popup body when a button is clicked within each row of the table. The challenge I am fac ...

Changing Image to Different File Type Using Angular

In my Angular Typescript project, I am currently working on modifying a method that uploads an image using the input element of type file. However, I no longer have an input element and instead have the image file stored in the assets folder of the project ...

Utilizing the ngIf Statement with a Repeating Element: A Step-by-Step

I am working with an Angular Material table: (HTML) <table mat-table [dataSource]="dataSource" multiTemplateDataRows class="mat-elevation-z8"> <ng-container matColumnDef="{{column}}" *ngFor="le ...

Enabling scrolling for a designated section of the website

Example Link to Plunker <clr-main-container> <div class="content-container"> <div class="content-area"> <div class="row"> <div class="col-xs-9" style="height:100%; border-right: 1px solid rgb(204, 204, 204); padding-ri ...

Can I use AJAX to load an entire PHP file?

My goal is to trigger a PHP file for sending an email when the countdown I created reaches zero. The PHP code contains the email message and does not involve any UI elements. I suspect that my approach may be incorrect, especially since I am not very fami ...

When using IndexedDB with a Javascript To-Do list, the dates for all items appear to be the same after adding a new item to the list

I developed a To-Do List using Javascript, HTML, and IndexedDB to store the items in the database so that they won't be deleted when the browser is refreshed. I also want to include the date for each item, however, whenever I add an item, the date end ...

Having difficulty defining the dropdown boundary in Bootstrap 5

Previously, I had this code working perfectly in Bootstrap 4. <div class="dropdown"> <span type="button" class="dropdown" data-toggle="dropdown" data-boundary="viewport"> <img src ...

What is the best way to iterate through and hide these images when they are clicked on?

I need help creating a grid of images inside divs that function like checkboxes. When you click on an image, it should disappear, and clicking again should make it reappear. I have some code that works for one image, but I can't figure out how to loop ...

Is it possible to generate a table without any grid lines present?

Currently, I am in the process of designing a table that will function as a popup when a link is clicked within my imported SQL table. An example of this table is included with this message for reference. After conducting thorough research, I attempted to ...

The iframe is not large enough to contain all the HTML content

I'm encountering a problem with a website I'm currently developing - specifically, I am struggling to embed an HTML document into an iframe in a manner that fills the entire page. Additionally, I am utilizing Angular to retrieve the HTML document ...

Tips for Enhancing JavaScript Performance

Is there a way to enhance my JavaScript code like this: $(window).scroll(function() { if ($('#sec1').isVisible()) { $('.js-nav a.m1').addClass('active'); } else { $('.js-nav a.m1').removeClas ...