2014-04-12 41 views
-1

这里是我的html:本地存储取指标?

<table> 
     <thead> 
      <tr style = 'background-color: white'> 
       <th> <i class="fa fa-male"></i> Name </th> 
       <th><i class="fa fa-bars"></i> Particular</th> 
       <th><i class="fa fa-envelope-o"></i>Unit</th> 
       <th><i class="fa fa-map-marker"></i>Quantity</th> 
       <th><i class="fa fa-phone"></i>From</th> 
       <th><i class="fa fa-phone"></i>Cost</th> 
       <th><i class="fa fa-phone"></i>Total</th> 
       <th><i class="fa fa-phone"></i>TAKE actions</th> 
      </tr> 
     </thead> 
     <tbody> 

       <tr> 
       <td>Mobile</td> 
       <td>nokia rerihh</td> 
       <td>LVP</td> 
       <td>77</td> 
       <td>Snehpandya</td> 
       <td>777</td> 
       <td>59829</td> 
       <td> 
        <form action="/requisitions/5" class="button_to" method="get"><div><input class="po" data-confirm="Really wants to generate Po?" type="submit" value="Send for approval -&gt;" /></div></form> 

       </td> 
      <tr> 
       <tr> 
       <td>Table</td> 
       <td>sneh is a good boy</td> 
       <td>LVP</td> 
       <td>7</td> 
       <td>Snehpandya</td> 
       <td>78</td> 
       <td>546</td> 
       <td> 
        <form action="/requisitions/6" class="button_to" method="get"><div><input class="po" data-confirm="Really wants to generate Po?" type="submit" value="Send for approval -&gt;" /></div></form> 

       </td> 
      <tr> 
       <tr> 
       <td>Mobile</td> 
       <td>jskfbhksjfkjfgweh</td> 
       <td>LVP</td> 
       <td>7</td> 
       <td>Anil</td> 
       <td>77</td> 
       <td>539</td> 
       <td> 
        <form action="/requisitions/7" class="button_to" method="get"><div><input class="po" data-confirm="Really wants to generate Po?" type="submit" value="Send for approval -&gt;" /></div></form> 

       </td> 
      <tr> 
     </tbody> 
    </table> 

在我的jQuery的;

$(document).ready(function(){ 

$(".po").click(function(e){ 

    localStorage.setItem("visited" + $(this).closest("tr").index(), true); 
    $(this).css("color", "red"); // visited 
}); 

for(var i = 0, len = $(".po").length; i < len; i++){ 

    if(localStorage.getItem("visited" + i)){ 

     $(".po:eq(" + i + ")").css("color", "yellow"); // visited 
    }else 
    { 
     $(".po:eq(" + i + ")").css("color", "black"); // not visited 
    } 
} 
}); 

问题是,它仅在crome

visited0 = true 
visited2 = true 
visited4 = true 

产生甚至走访=真我想让它正常1,2,3,4我哪里错了?

+0

您的标记是错误的。你有''而不是'',这意味着你每隔一段时间就要增加一个空行。 –

回答

1

您没有关闭行。

<tr> 
       <td>Mobile</td> 
       <td>nokia rerihh</td> 
       <td>LVP</td> 
       <td>77</td> 
       <td>Snehpandya</td> 
       <td>777</td> 
       <td>59829</td> 
       <td> 
        <form action="/requisitions/5" class="button_to" method="get"><div><input class="po" data-confirm="Really wants to generate Po?" type="submit" value="Send for approval -&gt;" /></div></form> 

       </td> 
      <tr> 

必须

<tr> 
       <td>Mobile</td> 
       <td>nokia rerihh</td> 
       <td>LVP</td> 
       <td>77</td> 
       <td>Snehpandya</td> 
       <td>777</td> 
       <td>59829</td> 
       <td> 
        <form action="/requisitions/5" class="button_to" method="get"><div><input class="po" data-confirm="Really wants to generate Po?" type="submit" value="Send for approval -&gt;" /></div></form> 

       </td> 
      </tr> 
+0

谢谢你,并为这样一个愚蠢的问题抱歉 –