Reputation: 171
<ul id="temp-list">
<li id="CommCheck" > Comm Check </li>
<input id="CommCheck-data" type="hidden" value="text1" />
....
</ul>
var vdata = $(ui.draggable).attr("id")+'-data'; /this gives me the CommCheck-data
alert(vdata);
var text-data = $(vdata).val(); // should give me the value of Input id: "CommCheck-data"
alert(text-data); // but this states undefined ???
how do i get the input value ? am I doing something wrong ?
Upvotes: 1
Views: 7870
Reputation: 93664
You need a "#" in front to tell jQuery it's an ID, not a tag name:
$("#" + vdata).val();
Also javascript variables cannot contain dashes in them. Try var textData
.
Upvotes: 4