I have the following code, and I want to select the element with type = text and id of 'announcement_date'. How would I do this in jQuery? Note that both the elements have same id. This is in a legacy classic ASP page I am working with.
<input type="hidden" name="announcement_date" id="announcement_date" value="1111"></input>
<input type="text" name="announcement_date" id="announcement_date" value="323"></input>
<input type="text" name="eff_date" id="eff_date" value="123"></input>
<input type="text" name="end_date" id="end_date" value="123"></input>
I tried the selector below, but it fails to select the correct element.
$("#announcement_date type=text").addClass("error");
IDs have to be unique.
(if for some reason you cannot change the html) you can select by name though as
$('input[name="announcement_date"][type="text"]');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With