私が達成しようとしているのは、Div 1をクリックしたときにメニューがスライドしてWeb 1を選択したときに、メニューが閉じ、iframeが変更されます。iframeターゲットを変更して1つのボタンからターゲットdivを閉じる
現在のところ、メニューを非表示にするかiframeを変更するだけではなく、両方では機能しません。
iframeの変更を示すために2番目の「Div 2」を追加しました。
<html>
<head>
<script src="https://code.jquery.com/jquery-3.2.0.js" integrity="sha256-wPFJNIFlVY49B+CuAIrDr932XSb6Jk3J1M22M3E2ylQ=" crossorigin="anonymous"></script>
<style>
.targetDiv {
display: none;
background-color: red;
width: 200px;
height: 100px;
display: none;
position: absolute;
left: 10px;
top: 50px;
}
.iframe {
bottom: 0px;
left: 0px;
position: absolute;
width: 500px;
height: 500px;
}
</style>
</head>
<body>
<div>
<a class="showSingle">Div 1</a>
</div>
<div>
<a class="showSingle">Div 2</a>
</div>
<div class="targetDiv">
<a href="http://www.skysports.com/" class="showSingle" target="myiframe">Web 1</a>
</div>
<div class="targetDiv">
<a href="http://www.bbc.co.uk/news" target="myiframe">Web 2</a>
</div>
<iframe src="http://www.bing.com/" name="myiframe" class="iframe"></iframe>
</body>
</html>
<script>
jQuery(function() {
jQuery('.showSingle').click(function() {
var index = $(this).parent().index(),
newTarget = jQuery('.targetDiv').eq(index);
jQuery('.targetDiv').not(newTarget).slideUp('fast')
newTarget.delay('fast').slideToggle('fast')
return false;
})
});;
</script>
あなたの質問は不明であるが、迅速な解決がされる追加する 'クラス= "showSingleは、"' 'テキストWeb2'を持つ' A'に、あなたはそれを忘れてしまいました。 – rmalviya