title: addclass() working in console but not working in script
body: <p>I have created a div dynamically. tried to add class as expanded through <code>jquery</code> its not working. But i tried the code in console, its working fine there.</p>
  
  <p>code are follows:</p>
  
  <p>appending element name</p>
  
  <pre><code>var menuId= '#itemMenu' + indexOfElement;
  </code></pre>
  
  <p>and then tried this</p>
  
  <pre><code>$(menuId).addClass('expanded');
  </code></pre>
  
  <p>when i tried folllowing in console</p>
  
  <p>e.g.     <code>$('#itemMenu5').addClass('expanded')</code></p>
  
  <p>its working fine..</p>