I have an input
<input type="text"开发者_如何转开发 value="hello" />
and I want to get the value of this and using Jquery, save the value in an array.
How can I do this???
using jQuery,
$(document).ready(function(){
var arr = [];
arr.push($('#inputID').val());
})
you should give your input an id
<input type="text" value="hello" id="inputID" />
you could run this code for submitting:
$('formname').submit(function() {
alert($(this).serialize());
return false;
});
This would return a string like:
a=1
You could then save this to an array.
var formValues = $('#your_form').serialize();
var formValuesAsArray = $('#your_form').serializeArray();
To get the value from your input, you should give it a name
attribute; for example <input type="text" name="message" />
and get its value by $('input[name=message]').val()
精彩评论