selecting elements by value
Hi All,
I'm new to jquery so pardon my ignorance but is there an easy way to select a hidden field by it's value? I have a table with multiple rows:
- <row> hidden field (serial number) + checkbox + label
- <row> hidden field (serial number) + checkbox + label
- <row> hidden field (serial number) + checkbox + label
- <row> hidden field (serial number) + checkbox + label
- <row> hidden field (serial number) + checkbox + label
I've got a function which takes in a serial number and I want to find the label corresponding to it and set it's value. This is what I have currently:
- $("input:hidden[@value='" + serialNumber + "']").each(function () {
- // update status - this is sibling to the hidden field
- $(this).siblings("span[@name *= 'lblFeedback']").each(function () {
- this.innerText = resultFeedback;
- });
- });
But unfortunately this returns all hidden fields. Is there a nice way of doing using selectors or is the only way to do this like this:
- // find the hidden field with that serial number
- $("input:hidden").each(function () {
- if ($(this).val() == serialNumber) {
-
- // update status - this is sibling to the hidden field
- $(this).siblings("span[@name *= 'lblFeedback']").each(function () {
- this.innerText = resultFeedback;
- });
- }
- });
Thanks
Sidharth