0
I am loading data from an external api with json and jquery,every ajax request a div with the item class, a div with the more_info class and a see button plus, which loads the rest of the data, and the created Divs receive the json data. Starting from line 28 jquery hides the div more_info, and the button created with the bt_ver_more class receives the toggle function, to open the rest of the information on the same screen. The problem is that when I click on one of the generated buttons to see more, all the buttons run the toggle function, opening the rest of the information of all the Divs, being obvious, since everyone has the same class, but I don’t want that to happen, I want to click button, He opens the div. more_info of his div, and not of all other Ivs
//Carrega dados de um arquivo json
var elemento;
$(document).on('click','#bt_prosseguir', function(){
$.getJSON('https://upvagasweb.000webhostapp.com/api_upvagas/php_json_access/access_json_aparecida.php', function(result){
elemento = "<div class='list radius white'>";
$.each(result, function(i, valor){
elemento += "<div class='item'>";
elemento += "<div class='left'>";
elemento += "<img class='avatar radius' src='"+valor.logo_empresa+"'>";
elemento += "</div>";
elemento += "<h2 style='margin-left:40%;'><strong>"+valor.setor+"</strong></h2>";
elemento += "<p style='margin-left:40%;'>"+valor.empresa+"</p>";
elemento += "<p style='margin-left:40%;'> Por "+valor.vinculo+"</p>";
elemento += "<p class='text-grey-500' style='margin-left:40%;'>"+valor.cidade+" - SP</p>";
elemento += "<p class='bt_ver_mais' style='margin-left:40%;color:#00f;'>Ver mais</p>";
elemento += "<div class='more_info'>";
elemento += "<p class='ver_mais' style='margin-left:40%;'><strong>Benefícios:</strong>"+valor.beneficios+"</p>";
elemento += "<p class='ver_mais' style='margin-left:40%;'><strong>Remuneração</strong>"+valor.remuneracao+"</p>";
elemento += "<p class='ver_mais' style='margin-left:40%;'><strong>Nível de estágio:</strong>"+valor.nivel_estagio+"</p>";
elemento += "<p class='ver_mais' style='margin-left:40%;'><strong>Inscrição:</strong>"+valor.processo_seletivo+"</p>";
elemento += "</div>";
//elemento += "<a href='"+valor.contato+"' class='ver_mais' style='margin-left:40%;'><strong>Link:</strong>"+valor.contato+"</p>";
elemento += "</div>";
});
$('#feed_vagas').html(elemento);
//esconde a div more_info
$('.more_info').hide();
$('.bt_ver_mais').click( function(){
$('.more_info').toggle();
});
});
});
/*$(document).on('deviceready', function(){
load_feed();
});*/
Thank you very much Sam, solved my problem at first, I was breaking my head too much with this kkk, I even tried jquery’s eq() method,!
– Luan Rodrigues