Reputation: 4352
I am trying to hide a span but having some trouble doing so. I want to get all the spans based on their for tag value and simply hide them. My question is, is it possible to get span's where there for tag equals something?
For example:
<input type="text" id="Address1" />
<span for="Address1" class="field-error">Boo</span>
<input type="text" id="Address2" />
<span for="Address2" class="field-error">Hoo</span>
JQUERY
$("#btn1").click(function() {
$("span.field-error").hide();
});
Thanks in advance, DS.
Upvotes: 0
Views: 213
Reputation: 146191
You may try this
$("span[for='Address1']").hide();
But it's not valid for span, instead you can use data-
prefix for custom attributes, like
<span data-for="Address1">some text</span>
Then, js
could be
$("span[data-for='Address1']").hide();
Upvotes: 2