0
I’m having the following problem when asking jquery to open the form it ends up opening all at once to send a reply in the comment, but I need it to open only what clickei as I do it. Follow the code.
javascript
$(document).ready(function(){
$('.resposta').click(function(){
var id = $(this).children('input').val();
var resposta = $('.restposta').id;
$('.resposta').fadeOut("fast");
$('.resp').fadeIn("fast");
});
return false;
});
Php that takes the database data
<?php
/*
**********************************************
**********************************************
***********Função para exibição dos***********
****************comentarios*******************
**********************************************/
$comentar = new Read;
$comentar ->ExeRead('coment', 'WHERE video = :video ORDER BY id DESC LIMIT 4', "video={$sei[1]}");
foreach ($comentar->getResult() as $big):
extract($big);
$image = new Read;
$image ->ExeRead('users', 'WHERE id = :id', "id={$big['user']}");
foreach ($image->getResult() as $imx)
extract ($imx);
/*
**********************************************
**********************************************
*********Fim da função de exibição************
***************de comentarios*****************
**********************************************/
echo "<input type='text' hidden='hidden' value='{$link}' id='link'>";
?><div class='comentar fl-left'><div class='coment com' >
<?php
if($foto == "" || $foto == "uploads/"):
echo "<a href='user?id={$id}'><img class='fl-left' src='".REQUIRE_PATH."/css/boot/icons/thumb.png'></a>";
else:
echo "<a href='user?id={$id}'><img class='fl-left' src='{$imx['foto']}'></a>";
endif;
echo "<p><small class='fontze1'>Comentado por:</small> {$nome} <small>Em: </small> {$date} <small>As: </small> {$hora}</p>
<p>".nl2br($comentario)."</p><div class='btn btn-green fl-right resposta'>Responder <input type='hidden' value='$big[id]' name='idcoment'></div><div class=' resp' style='display:none'><form method='post'>
<textarea></textarea> <input class='btn btn-green' type='submit' value='responder' name='responder'>
</form></div></div>";
endforeach;
endforeach;
endforeach;
Edit: I also noticed that when clicking on show more those that appear on the page do not work the response function does not open anything and was to be opening when clicked it does not perform any action
I made the changes you mentioned also in the parts that are in echo with php and I left everything as html to improve the code and leave faster loading. made the change in the javascript code that worked right, so every time I click on an element by placing this same element so it just opens the right clicked element ?
– Guilherme Sousa