Reputation: 87
$('.aggiungi_play').click(function() {
// find the class
pulsante_aggiungi = $(this);
//find the prev class where next I write a ajax content
spazio_canzone = pulsante_aggiungi.prev('.titolo_autore_codice_selezionata');
// find next div
div_right_click = $(this).next('.click_play_right');
$.ajax({
type: "POST",
url: "includes/query_temp_inserita_play.php",
data: {
id_cella_canzone_selezionata: id_cella_canzone_selezionata
},
dataType: "json",
cache: false,
success: function(scrivo_canzone) {
JSON.stringify(scrivo_canzone); //to string
// scrivo il titolo della canzone
$(spazio_canzone).html(scrivo_canzone.titolo_autore_temp);
},
error: function() {
alert("Sovraccarico del server. Clicca ok e poi ritenta. Grazie");
}
})
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="spazio_canzoni_playlist bg-warning">
<div class="orario_playlist">12:40</div>
<div class="titolo_autore_codice_selezionata">TEXT - TEXT</div>
<div class="aggiungi_play" rel="4157">
<div class="btn btn-danger btn-md">Inserisci</div>
</div>
<div class="click_play_right start">
<input type="hidden" class="canzone_file" value="value to find">
</div>
</div>
So I want to find the input value closest, next in this hidden input I want write my new content with ajax function. I want to find this value
<input type="hidden" class="canzone_file" value="value to find">
So my problem is select that input file I try with next, nextAll, find, closest but nothing
how can get it and then write in this the new value? Then with the ajax function I want to write a new value into the field
<input type="hidden" class="canzone_file" value="value to find">
thanks
Upvotes: 1
Views: 40
Reputation: 67525
You could simply use next and find like :
$('.aggiungi_play').click(function() {
console.log( $(this).next('.click_play_right').find('.canzone_file').val() );
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="spazio_canzoni_playlist bg-warning">
<div class="orario_playlist">12:40</div>
<div class="titolo_autore_codice_selezionata">TEXT - TEXT</div>
<div class="aggiungi_play" rel="4157">
<div class="btn btn-danger btn-md">Inserisci</div>
</div>
<div class="click_play_right start">
<input type="hidden" class="canzone_file" value="value to find">
</div>
</div>
Upvotes: 1