Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery get input value inside list which is inside a div

Tags:

jquery

I have something like the following

<div id="container">
      <ul id="name_list">
          <li class="name">
             <input type="hidden" class="name_val" value="5" />
          </li>
      </ul>
</div>

I am trying to get the value of the input. So far I have the following Jquery statment.

$("#container li.name input.name_val").val();

this does not work anyone know a better way?

like image 614
McNabbToSkins Avatar asked Apr 13 '10 12:04

McNabbToSkins


1 Answers

You were having a typo in your input class name

$("#container li.name input.name_val").val();

Also you can change your selector to something like

$("#name_list > li.name > input:hidden.name_val").val();
like image 65
rahul Avatar answered Sep 20 '22 12:09

rahul