使用delegate()优化以下代码段的最佳方法是什么?
jQuery('.menu').delegate('li.gallery', 'hover', function () { jQuery(this).children('.submenu').toggleClass('hide show'); });
jQuery('.menu').delegate('li.interior', 'hover', function () { jQuery(this).children('.submenu').toggleClass('hide show'); });
jQuery('.menu').delegate('li.exterior', 'hover', function () { jQuery(this).children('.submenu').toggleClass('hide show'); });
<li class="gallery">
<span>gallery</span>
<ul class="submenu hide">
<li class="interior">
<a href="/gallery/interior">Interior</a>
<ul class="submenu hide">
<li><a href="/gallery/interior?gallery=master-bedroom">Master Bedroom</a></li>
<li><a href="/gallery/interior?gallery=living-room">Living Room</a></li>
<li><a href="/gallery/interior?gallery=dining-room">Dining Room</a></li>
<li><a href="/gallery/interior?gallery=kitchen">Kitchen</a></li>
<li><a href="/gallery/interior?gallery=bathroom">Bathroom</a></li>
<li><a href="/gallery/interior?gallery=foyer">Foyer</a></li>
<li><a href="/gallery/interior?gallery=study">Study</a></li>
<li><a href="/gallery/interior?gallery=sunroom">Sunroom</a></li>
<li><a href="/gallery/interior?gallery=guest-room">Guest Room</a></li>
</ul>
</li>
<li class="exterior">
<a href="/gallery/exterior">Exterior</a>
<ul class="submenu hide">
<li><a href="/gallery/exterior?gallery=landscapes">Landscape</a></li>
<li><a href="/gallery/exterior?gallery=gardens">Gardens</a></li>
<li><a href="/gallery/exterior?gallery=cottages">Cottages</a></li>
<li><a href="/gallery/exterior?gallery=entry-driveway">Entry/Driveway</a></li>
</ul>
</li>
</ul>
</li>