skip to Main Content

Javascript – How to get the attribute of an innerHTML?

I'm trying to get the value of a span attribute (data-red) inside a table cell. <td class=" u-tL" headers="due-date" aria-labelledby="due-date"><span data-red="255" style="display: block; width: 75px;">19-JAN-2024</span></td> I've tried the code below but it's giving me the error "Uncaught TypeError: spn.getAttribute is…

VIEW QUESTION

Javascript – Detect the HD image size from the given src and srcset

This is my generated html code with the thumbnail being image-four-300x151.jpg and HD quality being image-four.jpg <figure class="wp-block-gallery has-nested-images columns-default is-cropped lightbox wp-block-gallery-1 is-layout-flex"> <figure class="wp-block-image size-medium"><img decoding="async" loading="lazy" width="300" height="151" data-id="218" src="http://localhost/demo/wp-content/uploads/2023/11/image-four-300x151.jpg" alt="" class="wp-image-218" srcset="http://localhost/demo/wp-content/uploads/2023/11/image-four-300x151.jpg 300w, http://localhost/demo/wp-content/uploads/2023/11/image-four-1024x517.jpg 1024w, http://localhost/demo/wp-content/uploads/2023/11/image-four-768x388.jpg…

VIEW QUESTION
Back To Top
Search