eq() is equivalent to selecting an item from an array and can be replaced by using bracket notation (e.g., arr[1]).
In D3 you can do selection.classed('active', false). This is equivalent to toggleClass().
According to jQuery's API, show() "... is roughly equivalent to calling .css( "display", "block"), except that the display property is restored to whatever it was initially." Instead of show, you can just do selection.transition().duration(300).style(display, 'block').
The length method? You can just use JavaScript's native .length.