Reputation: 303
I have some elements like TextBox
, Select
. I have a script to hide some elements. For this I use the code below, but it doesn't work:
$(document).on('change', '#TypeId', function (e) {
var selected = $(this).val();
if (selected == 1) {
$($('#Issue').parent(), $('#ServiceRequestId').parent()).hide();
console.log('test');
}
});
It just hides the first selector. When I change the selector like below it works fine:
$( $('#ServiceRequestId').parent()).hide();
Upvotes: 1
Views: 46
Reputation: 115202
The second argument is the context in jQuery which would help to filter element within that context.
I think you want to combine both objects, for that use add()
method to combine two independent jQuery objects.
$('#Issue').parent().add($('#ServiceRequestId').parent()).hide();
Or provide both jQuery objects within an array.
$([$('#Issue').parent(), $('#ServiceRequestId').parent()]).hide()
Upvotes: 2