Answer the question
In order to leave comments, you need to log in
How to get value?
How to receive and pass value ?
An example is html code:
<div class="item" value="800"></div>
<div class="item" value="801"></div>
<div class="item" value="802"></div>
<div class="item" value="803"></div>
var Vallue = $('#item_answer').attr("value");
$('.item'+Vallue+'').hide();
Answer the question
In order to leave comments, you need to log in
Didn't your mother tell you that you can't set attributes to elements, whatever you like (except perhaps data-what_you like )?
<div class="item" data-value="800"></div>
<div class="item" data-value="801"></div>
<div class="item800"></div>
<div class="item801"></div>
$(".item").each(function(){
var num = this.dataset.value;
$('.item'+num).hide();
});
You have written some heresy.
1) The class is item and the selector is "id= item_answer".
2) Further, in order not to write .attr("value"), you can simply write .val().
3) Vallue - this is a sign that you did not manage to come up with a variable name.
4) $('.item'+Vallue+'') = $(".item801") - do you have such classes? more precisely $(".item[value='+Vallue+']").hide
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question