1
I have this piece of Javascript/jQuery where I have a textarea
hidden and a href
. The intention is to click on href
to textarea
appear so the person can type in his or her answer.
I’m having trouble opening the textarea
in the href
correspondent.
By clicking on a href
, he opens all the questions.
<script>
$(document).ready(function() {
$.ajax({
type:'post',
dataType:'json',
url: 'listAllForum',
success: function(dados){
for(var i = 0; dados.length > i; i++){
$('#post-forum').append('<div>' + dados[i].idForum + ' - ' + dados[i].message + '</div>' +
'<div class="respostas" data-respostaId=' + dados[i].idForum + '>' +
'<textarea rows=6 cols=95 class="res" value="" name="dados" style="display:none;"/> <br>' +
'<a href="#" id="resp" class="resposta">Responder</a>' +
'</div> <br> <br>');
}
}
});
$(document).on('click', '.respostas', function (event) {
var idPergunta = $(this).attr('data-respostaId');
$('.res').show();
$.ajax({
type:'post',
dataType:'json',
url:'saveAnswer',
success: function(resposta){
}
});
event.preventDefault();
});
});
And the code, where it is??
– Aline