Is there a way to retrieve a
element's currently used source in javascript without using the viewport width / pixel density? Something similar to :selSolution 1:
The <picture> element is still experimental so I do not think there is an API to get the "active" source yet. I did however find the following issues for the <picture> spec expecting the element to have a currentSrc element.https://github.com/ResponsiveImagesCG/picture-element/issues/223currentSrc is the behaviour I also would have expected but currently it is simply not implemented in Chrome or FireFox.Solution 2:
You can, if you're using jQuery:$('img').on('load', function() {
console.log($(this)[0].currentSrc);
})
Copy
Share
Post a Comment
for " Src (active Source)"
Top Question
Right Floated Element Disappears When Using Columns In Firefox
I am using an ol element with column-count and column-gap p…
Remove The Button Inside The Dropdownlist
Is there a way to hide or remove the arrow button inside a …
Adding Asterisk To Placeholder, Or A Nice Way To Mark Required Fields Via Placeholder
I'm looking for a way to style the asterisk in the plac…
Mystery Margin Or Padding On List
I cannot figure out where the padding is coming from the on…
Homepage Slow To Load
When I go to the homepage of my website after clearing my c…
How To Add Placeholder Field?
I've been trying to add placeholder in input type='…
Continuous Image Swap While Mouse Is Hovering
i have an idea but i'm not quite sure how to execute it…
3 Columns + 100% Height
I need same as in the http://blog.html.it/layoutgala/Layout…
Escaping & > Characters In Ng-bind In AngularJs
I have a use case, where we can have '&' and &#…
Align Div Element To Bottom Of Container
I am trying to bottom align one of three divs inside a cont…