我使用jQuery和AJAX响应动态创建登录表单。窗体被创建并正确显示。但是,我无法阅读表单数据。使用jQuery获取文本框的值
这是我的代码:
$(document).ready(function(){
$('#proper-form').on('click', '#submit-button', function() { // loginForm is submitted
alert ("here");
var username = $('#email').attr('value'); // get username
var password = $('#password').attr('value'); // get password
alert (password);
alert (username);
// code for form submit using ajax
});
});
它提醒undefined undefined
两个用户名和密码。
任何人都可以帮我弄清楚这里有什么问题吗?
可能重复[?我如何使用jQuery文本框的值(http://stackoverflow.com/questions/463506/how-do- i-get-the-value-of-a-textbox-using-jquery) – senthilbp