Change ID with Jquery

2

My question is as follows. I have two audio tags in html, but one has the id="player", when I click on a button I want the id to change to the next tag. I have the following.

<audio id="player" data-value="dato">
<audio id="" data-value="segundodato">
<button id="boton" type="button">Siguiente</button

Could you help me fix it? I have nothing in Jquery yet.

    
asked by CobriiMusic Sz 05.12.2017 в 03:39
source

1 answer

2

You need to define the field of the next audio id

<audio id="player" data-value="dato">
<audio id="player2" data-value="segundodato">
<button id="boton" type="button">Siguiente</button>

$("#boton").click(function(){
   $("#player").removeAttr("id");
   $("#player2").attr("id","player");
});

As a result:

<audio data-value="dato">
<audio id="player" data-value="segundodato">
<button id="boton" type="button">Siguiente</button>
    
answered by 05.12.2017 в 04:50