如何使用JSON
和JSON
将提交的表单数据转换成localstorage
数组并将jQuery
数组存储到Javascript
中?以及如何在HTML
页上打印输出数据?
<form>
<label>Name</label>
<input id = "name" type = "text"/>
<label>Title</label>
<input id = "title" type = "text"/>
<label>Description</label>
<input id = "description" type = "text" rows="4" cols="50"/>
<label>New Comments</label>
<input id = "comments" type = "text" rows="4" cols="50"/>
<input type="radio" name = "icon"/> like
<input type="radio" name = "icon" /> unlike
<button id = "save" value = "submit">Save</button>
<button id = "display" value = "submit">Display</button>
</form>
答案 0 :(得分:0)
$( "form" ).submit(function( event ) {
console.log( $( this ).serializeArray() );
event.preventDefault();
});