tags:

views:

39

answers:

1

I have an array of input controls garnered like so:

   var hiddenInputs = $("input[id^='Unanswered']")

Each hidden input resides in a container which has another control which I am interested in getting the value of.

I iterate over the array of hiddenInputs

   $.each(hiddenInputs, function(i, val) {

Now, the element I would like to find belongs in the same container, so I can traverse up the DOM to the parent and then I want to get at element(s) which have the id which contains the text 'mainInputControl'

    var question = $(val).parent("input[id*='mainInputControl']");

    });

I am expecting the a shiny JQuery object to be nestling in question. What am I doing wrong?

Edit... For some further insight. This is what is in the children of the parent node: [input#Unanswered, input#ctl00_ContentPlaceHolder1_renderingEngine_ctl01_0_ctl00_0_ctl00_mainInputControl.hasDatepicker] I would like to get at second of these controls! Maybe I need to do the attribute selection within the children method()....

A: 

Im not sure if it is bad form to answer to yourself but here is the answer. Hope it helps

var hiddenInputs = $("input[id^='Unanswered']")

$.each(hiddenInputs, function(i, val) {
    var question = $(val).parent().children("[id*='mainInputControl']");
});
brumScouse