Кинда застрял на этом много часов, но я не могу узнать .parent()
или next()
или .next All()
для этого
Я хочу показать div
с именем .SubQuestion
на успехе ajax, когда .input-range
ползунок value
- это что-то, что Eavething отлично работает, за исключением
$(this).next(".SubQuestion").show();
и
$(this).next(".SubQuestion").hide();
я не могу найти мой div
класс display
и css
не работает
<div class="row">
<div class="col-9 my-1 input-ranges" id="range">
@{ var questionId = Model.QuestionAndAnswer[i].QuestionId;
var AcceptableScore = Model.QuestionAndAnswer[i].QuestionAcceptableScore;
}
@Html.TextBoxFor(model => model.QuestionAndAnswer[i].Ans_Score, htmlAttributes: new { @id = questionId, @tag = AcceptableScore, @class = "input-range", @min = "1", @max = "10", @step = "1", @type = "range" })
YourScore <span class="range-value">1</span>
</div>
<div class="col-3">
<a data-toggle="collapse" href="#ScoreComment_@i" role="button" aria-expanded="false" aria-controls="collapseExample">
<div class="fs-3x text-center text-info"><i class="la la-comment-o"></i></div>
</a>
</div>
<div class="col-12 bg-info SubQuestion" style="display:none">
<h1>Result</h1>
</div>
<div class="col-12">
<div class="collapse my-1" id="ScoreComment_@i">
@Html.TextAreaFor(model => model.QuestionAndAnswer[i].Ans_Score_Note, new { @class = "form-control p-1 w-100", @maxlength = "4000", @rows = "4", @placeholder = "توضیحات" })
</div>
</div>
</div>
<script>
$(function ($) {
console.log($.ajax);
$('.input-range').on('change', function () {
$(this).next('.range-value').html(this.value);
var questionId = $(this).attr("id");
var QAScore = $(this).attr("tag");
var rangevalue = $(this).nextAll('.range-value').first().text();
if (rangevalue < QAScore) {
$.ajax({
url: "/Question/GetSubQuestion",
type: "POST",
datatype: "json",
data: { QuestionId: questionId },
success: function (data) {
$(this).next(".SubQuestion").html(data);
$(this).next(".SubQuestion").show();
}
});
}
else {
$(this).parent().nextAll(".SubQuestion").hide();
}
});
});
</script>