我正在尝试点击页面顶部的按钮,点击它会打开位于页面底部的#iframe ID。通过点击并打开#iframe ID,我想从顶部跳到所述#iframe。
$(document).ready(function(){
$('#toggle_message').click(function(){
var value= $('#toggle_message').attr('value');
$('#iframe').toggle('fast');
if(value=='Vise Reserver Bord Her') {
$('#toggle_message').attr('value','Skjule Reservation');
} else if(value=='Skjule Reservation') {
$('#toggle_message').attr('value','Vise Reserver Bord Her');
}
})
$("#toggle-message").click(function() {
window.location.hash = "#"+$(this).attr("#iframe");
})
});
<div id="booking">
<input type="button" value="Vise Reserver Bord Her" id="toggle_message" />
</div>
<div id="column"> images here </div>
<div id="column_Two"> text boxes </div>
<div id="iframe_box">
<iframe id="iframe" src="link"></iframe>
</div>
答案 0 :(得分:1)
$(document).ready(function(){
$('#toggle_message').click(function(){
var value= $('#toggle_message').attr('value');
$('#iframe').toggle('fast');
location.href="#iframe";
if(value=='Vise Reserver Bord Her') {
$('#toggle_message').attr('value','Skjule Reservation');
}else if(value=='Skjule Reservation'){
$('#toggle_message').attr('value','Vise Reserver Bord Her');
location.href="#timing";
}
})
});