Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript添加一个浮动div测验按钮_Javascript_Jquery - Fatal编程技术网

javascript添加一个浮动div测验按钮

javascript添加一个浮动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=

我已经使用javascript创建了客户端测试

我想在页面中添加以下功能

1) 在测验DIV的中心有一个开始测验按钮,如果用户滚动页面,则开始测验按钮DIV在主菜单的下方始终可见

2) 如果用户启动了测验并滚动页面,则应在主菜单的下方显示“继续测验”按钮DIV


请回复。谢谢。

您需要创建变量

Apply fixed position

position:fixed 

in your stylesheet for your div id or class.
  • 如果用户已启动,则
    var quick=“start”

  • 如果用户必须启动,则
    var quick=“tostart”

  • 现在HTML将是:

    <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 */
    }
    
    您可以随时更改变量的值