javascript添加一个浮动div测验按钮
我已经使用javascript创建了客户端测试 我想在页面中添加以下功能 1) 在测验DIV的中心有一个开始测验按钮,如果用户滚动页面,则开始测验按钮DIV在主菜单的下方始终可见 2) 如果用户启动了测验并滚动页面,则应在主菜单的下方显示“继续测验”按钮DIVjavascript添加一个浮动div测验按钮,javascript,jquery,Javascript,Jquery,我已经使用javascript创建了客户端测试 我想在页面中添加以下功能 1) 在测验DIV的中心有一个开始测验按钮,如果用户滚动页面,则开始测验按钮DIV在主菜单的下方始终可见 2) 如果用户启动了测验并滚动页面,则应在主菜单的下方显示“继续测验”按钮DIV 请回复。谢谢。您需要创建变量 Apply fixed position position:fixed in your stylesheet for your div id or class. 如果用户已启动,则var quick=
请回复。谢谢。您需要创建变量
Apply fixed position
position:fixed
in your stylesheet for your div id or class.
var quick=“start”代码>
var quick=“tostart”代码>
<button class="button"></button>
if(quiz == "start") {
$('.button').text('Continue');
$('.button').css('position', 'fixed');
/* add other parameters as per need */
} else if(quiz == "tostart") {
$('.button').text('Start');
$('.button').css('position', 'fixed');
/* add other parameters as per need */
}
对于基本JS
if(quiz == "start") {
var button = document.getElementsByClassName("button");
button.innerHTML = "Continue";
button.style.position = "fixed";
/* and same thing for the other half */
}
您可以随时更改变量的值