diff --git a/demos/tabs/manipulation.html b/demos/tabs/manipulation.html
index 205fc2e4d..085d42c43 100644
--- a/demos/tabs/manipulation.html
+++ b/demos/tabs/manipulation.html
@@ -76,8 +76,8 @@
// close icon: removing the tab on click
$( "#tabs span.ui-icon-close" ).live( "click", function() {
- $( this ).closest( "li" ).remove();
- $( "#" + $( this ).prev().attr( "aria-controls" ) ).remove();
+ var panelId = $( this ).closest( "li" ).remove().attr( "aria-controls" );
+ $( "#" + panelId ).remove();
tabs.tabs( "refresh" );
});
});