<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="4000">
<div class="carousel-inner">
<div class="item active" >
<h4>
<span class="answer"><%=questions[0].getText()%></span>
<div>
<br>
<% for(QuestionAnswer answer:questions[0].getQuestionAnswersSet())
{
%>
<input type="checkbox" class="answercheck <%= answer.getCorrect()==true? "checked":"unchecked" %>" />
<span class="answer"><%= answer.getText()%></span>
<br>
<%
}
%>
<br>
</div>
</h4>
</div>
<%
for(int i=1;i<questions.length;i++)
{
%>
<div class="item ">
<h4>
<span class="answer"><%=questions[i].getText()%></span>
<div>
<br>
<%
for(QuestionAnswer answer:questions[i].getQuestionAnswersSet())
{
%>
<input type="checkbox" class="answercheck <%= answer.getCorrect()==true? "checked":"unchecked" %>" />
<span class="answer"><%= answer.getText()%></span>
<br>
<%
}
%>
<br>
</div>
</h4>
</div>
<%
}
%>
</div>
</div>
<% } %>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function()
{
setTimeout(function(){ $(".checked" ).attr('checked', true)},2000);
});
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
I have used Jsp and Jquery. What is happening here is after 2 seconds, when the first question answers get clicked. The other question answers also ticked in a carousel which will come after 4 seconds as mentioned in data-interval
I want when the question display at that time only after 2 seconds my correct answer checkbox should get checked and it should apply to all the questions which are in the carousel item