Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用本地存储存储jquery mobile';什么是复选框状态? 1. 2. 3. 4. 5. 1. 2. 3. 4. 5._Javascript_Html_Jquery Mobile_Local Storage - Fatal编程技术网

Javascript 如何使用本地存储存储jquery mobile';什么是复选框状态? 1. 2. 3. 4. 5. 1. 2. 3. 4. 5.

Javascript 如何使用本地存储存储jquery mobile';什么是复选框状态? 1. 2. 3. 4. 5. 1. 2. 3. 4. 5.,javascript,html,jquery-mobile,local-storage,Javascript,Html,Jquery Mobile,Local Storage,我用jquery手机做了一张桌子。好的!然后我想隐藏一些列,所以我点击“列…”,现在我隐藏了这些列,但是我如何使用localstorage存储我的操作,当我刷新这个页面时,并不是所有的列都显示出来。我知道有“ui复选框打开”和“ui复选框关闭”。。。。 谢谢 要存储数据: <table data-role="table" data-mode="columntoggle" class="ui-responsive ui-shadow" data-column-btn-text="">

我用jquery手机做了一张桌子。好的!然后我想隐藏一些列,所以我点击“列…”,现在我隐藏了这些列,但是我如何使用localstorage存储我的操作,当我刷新这个页面时,并不是所有的列都显示出来。我知道有“ui复选框打开”和“ui复选框关闭”。。。。 谢谢

要存储数据:

<table data-role="table" data-mode="columntoggle" class="ui-responsive ui-shadow" data-column-btn-text="">
      <thead>
            <tr>
                <th data-priority="1" id="th0">1</th>
                <th data-priority="1" id="th1">2</th>
                <th data-priority="1" id="th2">3</th>
                <th data-priority="1" id="th3">4</th>
                <th data-priority="1" id="th4">5</th>
           </tr>
     </thead>
     <tbody>
           <tr>
                <td>1</td>
                <td>2</td>
                <td>3</td>
                <td>4</td>
                <td>5</td>
          </tr>
    </tbody>    
</table>
要检索数据,请执行以下操作:

localStorage.setItem("username", username);
在您的情况下,类似于:

HTML:

CSS:


JSFIDLE:

THx杜德!但我的问题是存储复选框状态抱歉。我已经用小提琴更新了答案。看看是否有帮助:
var username = localStorage.getItem("username");
<input type="checkbox" onclick="toggle('.myClass', this)" >
<div class="myClass">
   check 1.
</div>

<input type="checkbox"  onclick="toggle('.myClass2', this)" >
<div class="myClass2">
   check 2.
</div>

<input type="checkbox"  onclick="toggle('.myClass3', this)" >
<div class="myClass3">
   Check 3.
</div>
function toggle(className, obj) {
    var $input = $(obj);
    if ($input.prop('checked')) {
        $(className).css("visibility", "hidden");
        console.log(className);
        localStorage.setItem(className,'hidden')
    } 
    else {
        $(className).css("visibility", "visible");
        localStorage.setItem(className,'visible')
    }
}
input[type="checkbox"] {
  clear: both;
  float:left;  
}