隐藏/显示特定内容并另存为localStorage

时间:2015-09-19 20:14:15

标签: javascript jquery local-storage bootstrap-switch

我希望使用自举开关来隐藏和显示toggle个特定内容,具体取决于是否进行了检查。我想在localstorage中保存此复选框的状态。我是javascript的新手,无法解决这个问题。我将不胜感激任何帮助......

The jsfiddle is self-explanatory。我也会在这里粘贴代码。谢谢你!

<div class="well text-center">
  <h1>Today's Games</h1>
  <br>
  <input type="checkbox" name="spoiler-checkbox" data-size="mini" data-on-color="danger">
  <br />
  <label for="checkbox">Spoiler-Free</label>
</div>

<div class="col-xs-4 col-xs-offset-4">
  <table class="table table-bordered" id="Game1">
    <thead>
      <tr>
        <th class="status" colspan="3" id="timeleft">3:31 3rd Quarter</th>
        <th class="status" colspan="3" id="starttime">7:30pm EST</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="team" colspan="2">Bulls</td>
        <td class="score" colspan="1">59</td>
      </tr>
      <tr>
        <td class="team" colspan="2">Bucks</td>
        <td class="score" colspan="1">65</td>
      </tr>
    </tbody>
  </table>
</div>
#timeleft {
    color:red;
}

#starttime {
    display:none;
}

.team {
    font-weight: 700;
}
$("[name='spoiler-checkbox']").bootstrapSwitch();

更新

K,在多个来源的帮助下,我的工作非常好。不是最干净的代码,而是完全按照我的意愿行事。

http://jsfiddle.net/j9knzuh1/28/

0 个答案:

没有答案