开发者

jquery with index based radio button selected value help

I have following generated code and tried to retrive the radio button value or checked from below html generated code

HTML code generated :::

    <input type="radio"      name="mergedServiceSets[0].cdaQuestionnaireresponses[0].questionnaire.value" id="SetUpTest_mergedServiceSets_0__cdaQuestionnaireresponses_0__questionnaire_valueY" value="Y" class="mergedServiceSets[0].cdaQuestionnaireresponses[0].questionInputRadio" onchange="javascript:dataModified();"/>&nbsp;Yes<br />

    <input type="radio" name="mergedServiceSets[0].cdaQuestionnaireresponses[0].questionnaire.value" id="SetUpTest_mergedServiceSets_0__cdaQuestionnaireresponses_0__questionnaire_valueN" value="N" class="mergedServiceSets[0].cdaQuestionnaireresponses[0].questionInputRadio" onchange="javascript:dataModified();"/>&nbsp;No<br />

Jquery1.6.1 used :

var questionInputRadio = $(".mergedServic开发者_开发百科eSets[" + i + "].cdaQuestionnaireresponses[" + j + "].questionInputRadio");

where i and j are passed dynamically . or

alert("questionInputRadio===" + $(".mergedServiceSets[0].cdaQuestionnaireresponses[0].questionInputRadio").val());

Actual results ::: undefined is displaying when i see in alert box .

It never works for index based classes or ids in jquery . please help


You need to escape [, ] and . in your selector. Something like:

$(".mergedServiceSets\\[" + i + "\\]\\.cdaQuestionnaireresponses\\[" + j + "\\]\\.questionInputRadio");

Edit: I'm actually not sure if those characters are even technically valid.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜