Reputation: 41
I am new to Jquery. And facing some issue while accessing dynamic element from my JSP using JQuery
It works fine for me when I tried below code:
function getListElement(index)
{
document.getElementById('dataList['+index+'].firstName').value;
}
Its not work when I tried below code:
function getListElement(index)
{
$("#dataList["+index+"].firstName").val();
}
Why 2nd point is not working may I know reason...... :(
Is there any other syntax to get that value....?
Thanks In Advance.....:)
Upvotes: 1
Views: 609
Reputation: 78630
$("#dataList\\["+index+"\\]\\.firstName").val();
[]
and .
have special meaning in a selector. You might consider simplifying your id
s.
Upvotes: 3