1
<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 ?

1
  • 1
    That isn't your actual HTML markup is it? An <input> can't be a direct child of a <ul> element. Commented Jan 3, 2011 at 6:19

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.