title: How to check if localStorage value is in array?
body: <p>Based on <a href="https://stackoverflow.com/questions/18867599/jquery-inarray-how-to-use-it-right">this answer</a> I should be using <code>$.inArray</code>, therefore I do:</p>
  
  <pre><code>var curPostId = $(".my_post_id").attr("data-id");
  
  if($.inArray(curPostId, lines)) {
    $('#'+localStorage.getItem('saveButton')).attr('disabled', true);
  }
  </code></pre>
  
  <p>If I do: console.log(curPostId); I get <code>248</code> which is correct. Then if I do <code>console.log(lines);</code> I get <code>[242, 248]</code></p>
  
  <p>Lines is defined like this:</p>
  
  <pre><code>var lines = localStorage.getItem("lines") ? JSON.parse(localStorage.getItem("lines")) : [];
  </code></pre>
  
  <p>But the check if it's in Array doesn't happen as this it's not applied <code>$('#'+localStorage.getItem('saveButton')).attr('disabled', true);</code></p>
  
  <p>This is how I set daveButton on local storage</p>
  
  <pre><code>$(".save_post").on("click", function() {
    if (counter &gt;= 2) { 
      alert('nope'); 
      return; 
    } else {
      $(this).attr("disabled", "true");
      localStorage.setItem('saveButton', $(this).attr('id'));
      var thisId = $(".my_post_id").attr("data-id");
      lines.push(thisId);
      localStorage.setItem("lines", JSON.stringify(lines));
    }
  });
  </code></pre>
  
  <p>This question is a follow up to my previous question <a href="https://stackoverflow.com/questions/49561164/how-to-keep-button-state-across-different-pages?noredirect=1#comment86130544_49561164">how to keep button state across different pages</a> which has an answer that works but only partly.</p>