Reputation: 10854
I have main div with an ID of mvrContentFormDiv
. Inside there, there are 4 child div's with IDs of reportFileURL
, UploadReportDate
, reportTitle
& reportImageURL
.
Each of these have a class of error
. Right now I am removing that class individually using the following code, but would like to use removeClass
from the parent DIV.
$("#reportFileURL").removeClass("error");
$("#uploadReportDate").removeClass("error");
$("#reportTitle").removeClass("error");
$("#reportImageURL").removeClass("error");
Can anyone explain how I can do this?
Upvotes: 1
Views: 537
Reputation: 296
Try this:
$("#mvrContentFormDiv").children().removeClass("error");
Upvotes: 1
Reputation: 12128
try something like that:
$("#mvrContentFormDiv div").removeClass("error");
being 'mvrContentFormDiv' your parent id
Upvotes: 2
Reputation: 123397
unless you have other elements with that class elsewhere in the document that have to be untouched, you could simply do
$('.error').removeClass("error");
otherwise
$('<parentelement> .error').removeClass("error");
Upvotes: 3
Reputation: 75317
You could use the children()
method or child selector to select them from the mvrContentFormDiv
:
$('#mvrContentFormDiv > .error').removeClass('error');
or
$('#mvrContentFormDiv').children('.error').removeClass('error');
Upvotes: 5