同様のコンテンツを表示する複数のタブを含むページがあります。正しいタブの正しいフィールドにアクセスできるようにするために、ユーザーがタブをクリックするとすぐに他のタブの div のコンテンツをクリアしたいと考えています。
これは私が使用するコードです:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>WebShop</title>
<link rel="stylesheet" type="text/css" href="/includes/igepa.css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<link rel="stylesheet" href="/resources/demos/style.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script>
$(function() {
$( "#tabs" ).tabs({
beforeLoad: function( event, ui ) {
ui.jqXHR.error(function() {
ui.panel.html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo." );
});
},
load: function(event, ui){
$('.ui-tabs-hide').empty();
}
});
});
</script>
</head>
<body>
<div id="tabs">
<ul>
<li><a href="/itemStructPaper/Enveloppen">Enveloppen</a></li>
<li><a href="/itemStructPaper/GrafischKarton">Grafisch karton</a></li>
</ul>
</div>
</body>
</html>
ここに例を追加しました: http://www.igepa.be/phdj/tabs/index.htm
page1.htm と page2.htm には同じフィールドを持つフォームがありますが、値は異なりますが、2 ページ目のタブを選択すると、1 ページ目のフィールドの値が取得されます。