Reputation: 1017
I am trying to change multipele variables at the same time, but haven't found a way to do it currently. The code that I have currently looks like this
search = $("#search"),
drop = $("#drop");
search.prop("disabled", true).css("display","none");
drop.prop("disabled", true).css("display","none");
But I want to set those two variables on the same line if that is possible without making them into one variable
Upvotes: 0
Views: 34
Reputation: 4937
$("#search,#drop").prop("disabled", true).css("display","none");
Though, you can also do it this way;
$("#search,#drop").prop("disabled", true);
$("#search,#drop").css("display","none");
Upvotes: 2
Reputation: 4366
Use multiple selector elements. You can also play with hide()
/show()
methods instead of css display none:
$("#search, #drop").prop("disabled", true).hide();
Upvotes: 1
Reputation: 4920
You can do it like this using multiselector in jquery
Multiple Selector (“selector1, selector2, selectorN”)
$("#search, #drop").prop("disabled", true).css("display","none");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p id="search">Search</p>
<p id="drop">Drop</p>
<p>hi</p>
Upvotes: 0