I am trying to create a Typescript function that will locate the next div and apply a CSS class to it. Here is what I have attempted:
<ul>
<li><a href="#" onclick="toggle()">Item 1</a></li>
<div class="content hide"></div>
<li><a href="#" onclick="toggle()">Item 2</a></li>
<div class="content hide"></div>
<li><a href="#" onclick="toggle()">Item 3</a></li>
<div class="content hide"></div>
<li><a href="#" onclick="toggle()">Item 4</a></li>
<div class="content hide"></div>
<li><a href="#" onclick="toggle()">Item 5</a></li>
<div class="content hide"></div>
</ul>
Here is my attempt at the Typescript function:
function toggle(){
this.parent().next('.content').class('hide');
}
Any suggestions or feedback would be greatly appreciated.