2

I'm trying to get value from input tag but it returns an empty string. When I open frame source it shows something like

<input type="hidden" name="" class="code_item" value="00-00000159" />

To get value I'm trying with

$(this).children('td').children('.code_item').value 

Please, help me to find the error, I'm new for this.

3
  • Sorry. " something like <input type="hidden" name="" class="code_item" value="00-00000159" /> " Commented Jun 14, 2016 at 11:45
  • 3
    $(this).children('td').children('.code_item').val() Commented Jun 14, 2016 at 11:46
  • 1
    Please provide the html code relevant to this as well, and if it is an iframe and your javascript is outside, you maynot be able to access the inner components depending on whether there is a cross domain issue. And if they are of same origin, then it is still not as direct as above. Commented Jun 14, 2016 at 11:46

2 Answers 2

1

In jquery use .val() instead of .value

$(this).children('td').children('.code_item').val()
Sign up to request clarification or add additional context in comments.

1 Comment

or $(this).children('td').children('.code_item')[0].value
0

Because you're using jquery selectors you should use val() instead of .value :

$(this).children('td').children('.code_item').val()

Or add [0] to return javascript object then you could use .value :

$(this).children('td').children('.code_item')[0].value

It could be done also without using children() :

$('td .code_item', this).val();

Hope this helps.

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.