Home > Enterprise >  get current image from picture html tag
get current image from picture html tag

Time:08-12

<picture>
    <source media="(min-width: 992px)" srcset="/images/xxxxxxxxxx.jpg">
    <source media="(min-width: 768px)" srcset="/images/yyyyyyyyyy.jpg">
    <img src="/images/zzzzzzzzzz.jpg">
</picture>

I need to assign the active image or another tag. How can I get it with jquery or CSS?

CodePudding user response:

Try this:

$('picture > img').attr('src'); //will return current image, you can use it anywhere !

i hope it was useful

CodePudding user response:

Did you put this line in your head tag?

<meta name="viewport" content="width=device-width, initial-scale=1.0">
  • Related