hideNote = function functionName(hideNum) { var obj = JSON.parse(localStorage.getItem(localStorage.key(hideNum))); console.log(obj.id); //правильный id var a = obj.id; var ind = $(this).attr('a'); $('div [id='+ind+']' ).hide();/* var divToHide = document.getElementsById(obj.id); divToHide.style.visibility="hidden"; //element.style.visibility = 'hidden';*/ }, 

You need to hide a div with a specific id, obtained from localStorage .
What am I doing wrong?

  • You have ind - is the attribute a , what's the id ? - vp_arth
  • one
    Maybe $('#'+obj.id).hide() ? - vp_arth

2 answers 2

If obj.id contains the correct id then use it and do not need to write too much

 $('#'+obj.id ).hide(); 

    There are several ways:

    1.js + css property

      var elem1 = document.getElementById(obj.id); elem1.style.display = 'none'; 

    2.jquery

     $('#' + obj.id).hide();