Get image address, jquery

1

Hello, good morning!

I would like to get the SRC value of the IMG tag, using js / jquery. In this case, it would be link

<html>
    <head>
        <title>hello</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script>functionget(){//????//alert(img);alert('a');}</script></head><bodyonload="get()">
        <img src="https://i.imgur.com/1gIalgU.jpg"width="100" height="100">
    </body>
</html>

Is it possible?

    
asked by anonymous 03.11.2018 / 17:16

1 answer

3

Do this:

<html>
    <head>
        <title>hello</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script>functionget(){varlinkImagem=$('#imagem').attr('src');alert(linkImagem);}</script></head><bodyonload="get()">
        <img src="https://i.imgur.com/1gIalgU.jpg"width="100" height="100" id="imagem">
    </body>
</html>
    
03.11.2018 / 17:24