簡體   English   中英

如何使用JQUERY將提交的表單數據轉換為json數組並將json數組存儲到localstorage

[英]How to convert submitted form data into a json array and store the json array into localstorage using JQUERY

如何提交的表單數據轉換成JSON陣列和存儲JSON數組localstorage使用jQueryJavascript 以及如何在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> 

jquery .serializeArray()

$( "form" ).submit(function( event ) {
   console.log( $( this ).serializeArray() );
   event.preventDefault();
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM