javascript - How do I build a valid JQuery selector using variables -
i trying build jquery selector. involves concatenating string , variables. however, reason, resulting selector comes invalid. have attempted number of options such this:
$('[name="[name='$radioname + (row_id) + ']"][value="$result"]').attr('checked',true);
$radioname
illustration is: 'nigeria[osun][okuku-;// angle bracket not closed row_id appended before closing bracket appended shown above.
$result
illustration is: '67
row_id
illustration is: 5
how may build valid descriptor these requirements?
thanks
try:
$('[name="' + $radioname + row_id + ']' + '"][value="' + $result + '"]').attr('checked',true);
when i'm putting concatenated expressions, using write static text proper quotes first. like:
$('[name=""][value=""]').attr('checked',true);
then paste in '+ +'
in each of spots want add together variable. so:
$('[name="'+ +'"][value="'+ +'"]').attr('checked',true);
then lastly, add together variable:
$('[name="'+ $radioname + row_id + ']' + '"][value="'+ $result +'"]').attr('checked',true);
javascript jquery html
No comments:
Post a Comment