Exchanging data-src by SRC [closed]

2

Good afternoon everyone!

I have a question, it can be simple (or not).

Can you change attribute?

Example, I have an img tag with a data-src attribute. I want to turn this data-src attribute into src.

So:

<img id="teste" data-src="link_da_imagem">

I want to like this:

<img id="teste" src="link_da_imagem">

Is there any JavaScript / JQuery function that does this?

Thank you!

EDIT

Guilherme, thank you!

The problem is this, I'll try to describe it.

I have a store, which the products to sample, look like this: link

When you click on the small image, the large image changes (Change in case, for which small image you clicked)

I need to have a merry-go-round, instead of clicking on the image, and moving it instead. In this case, stay like this: link

I'm using the owl-carousel, which in the case the script is this: link

In the store, these products here: link only the large image is in SRC, the small ones (left side ) are with date-src, so the carousel does not work, so it shows only the tag that has SRC and not DATA-SRC. If they understood and can help, I thank, if not, thank you anyway! :)

    
asked by anonymous 16.11.2016 / 17:11

1 answer

2

In your case it can be this way (Solution with jQuery):

$('#teste').attr({
        src : $('#teste').attr('data-src'),
    })
    .removeAttr('data-src')
;

Basically, you will create a new attribute and remove the old one, I think that renaming, exactly, is not possible.

    
16.11.2016 / 17:15