How to extract values within a span
I have a very complex situation. To reduce it to its basics ... First of this is a aspx csharp jquery ajax app
I am populating a with textboxes and other input controls at runtime using ajax sending html from the codebehind to the page and laying the html into a span.
Now I need to grab the values of these input control. I do not know in advance what these co开发者_运维技巧ntrols are except that they are one of several (input- text, checkbox, radio).How can I access all input values with a span in this case. The span could be another delimiter and I tried but my master page has a form and it is not (I am guessing) allowing me to place a form here.
My objective is to grab the values and return them via ajax and use them as search criteria to my search.
var inputValArray = [];
$('[span selector] input').each(function() { // $('[span selector] > input') for direct children only
inputValArray.push($(this).val());
});
span selector
could be id
or a css class
on the span. If you can update your question with some HTML or more info as to how you can distinguish this span, I can update my answer.
I don't quite follow your question; your situation must be very complex. In jQuery, you can use a selector like
var inputControls = $("#spanId :input")
to obtain a reference to all input controls inside your span. You could then use .each to process each one in turn.
精彩评论