title: Error while executing function cannot set property 'width'
body: <p>I call the <code>function</code> in this <code>div</code>:</p>
  
  <pre><code>&lt;div id="sideNavigation" class="sidenav"&gt;
  &lt;a href="javascript:void(0)" class="closebtn" onclick="closeNav()"&gt;&amp;times;&lt;/a&gt;
    &lt;a href="#"&gt;Caixa de entrada&lt;/a&gt;
      &lt;ul&gt;
          &lt;li&gt;&lt;a href="#s1" class="btn-show" data-element="#minhaDiv" style="font-size: 70%"&gt;Todas&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#s2" class="btn-show" data-element="#minhaDiv1" style="font-size: 70%"&gt;Geral&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#s3" class="btn-show" data-element="#minhaDiv2" style="font-size: 70%"&gt;Ocorrências&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;a href="#"&gt;Mensagens&lt;/a&gt;
      &lt;ul&gt;
          &lt;li&gt;&lt;a href="#s4" class="btn-show" data-element="#minhaDiv3" style="font-size: 70%"&gt;Enviadas&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#s5" class="btn-show" data-element="#minhaDiv4" style="font-size: 70%"&gt;Não lidas&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  
  &lt;/div&gt;
  &lt;nav class="topnav"&gt;
    &lt;a href="#" onclick="openNav()"&gt;
      &lt;svg width="30" height="30" id="icoOpen"&gt;
          &lt;path d="M0,5 30,5" stroke="#000" stroke-width="5"/&gt;
          &lt;path d="M0,14 30,14" stroke="#000" stroke-width="5"/&gt;
          &lt;path d="M0,23 30,23" stroke="#000" stroke-width="5"/&gt;
      &lt;/svg&gt;
    &lt;/a&gt;
  &lt;/nav&gt;
  
  &lt;div id="main"&gt;
  &lt;!-- Add all your websites page content here  --&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>javascript:</p>
  
  <pre><code>$('.topnav a').click(function(){
    $('#sideNavigation').style.width = "20%";
    $("#main").style.marginLeft = "20%";
  });
  
  $('.closebtn').click(function(){
    $('#sideNavigation').style.width = "0";
    $("#main").style.marginLeft = "0";
  });
  </code></pre>
  
  <p>When I run on the page and open or close the div, I get the following error:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot set property 'width' of undefined
        at HTMLAnchorElement.</p>
  </blockquote>