Get form element

Get form element

I am unable to get the form element due to some reason. Infact these elements are on bootstrap modal called by ajax.

Below is my code

<form action="#" method="post" id="myform">
<input type="text" class="name" placeholder="Your Name" id="name">
</form>


Below doesn't work:
name=$("input#name").val();
name=$("#name").val();
name=$("form#name").val();
name=$("#myform #name").val();
name=$("#myform input#name").val();