Save id of a cycled image (php / Javascript)

0

Hi, I'm new to jquery ...

I'm looking for information on how to save an id of a cycled image after this I need to take that id and use it in a form

Ex: I have multiple services such as selling: Tasones Dishes Glasses Etc.

After that at the time of taking said id the form has to send the quote, that I already have it ..

I would appreciate your help.

    
asked by H14rmy 11.06.2017 в 00:36
source

1 answer

0

In the click event handler you can access the element that has been pressed through this .

To access the id of the element you can use the attr method since jQuery treats the id as one more attribute:

$(function(){
  $('img').click(function(){
    var imageId = $(this).attr('id');
    $('#imagenPulsada').val(imageId);
  });
});
img {
  border: solid 1 px black;
  width: 100px;
  height: 100px;
  padding: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img id="imagen1" alt="imagen1" />
<img id="imagen2" alt="imagen2" />
<img id="imagen3" alt="imagen3" />
<img id="imagen4" alt="imagen4" />
<img id="imagen5" alt="imagen5" />
<img id="imagen6" alt="imagen6" />
<img id="imagen7" alt="imagen7" />

<input type="text" id="imagenPulsada" />
    
answered by 11.06.2017 в 00:45