zoukankan      html  css  js  c++  java
  • 模拟单选框

    <!--<div class="list">
    &lt;!&ndash;<input type="radio" id="student" name="role" class="uncheck">

    <span class="vir-check"></span>
    <label for="student">学生</label>&ndash;&gt;

    <span class="vir-check uncheck" id="student"></span><label for="student">学生</label>
    </div>
    &lt;!&ndash;专家登录&ndash;&gt;
    <div class="list">

    &lt;!&ndash;<input type="radio" id="speciallist" name="role" class="check">
    <span class="vir-check"></span>
    <label for="speciallist">专家</label>&ndash;&gt;

    <span class="vir-check uncheck" id="speciallist"></span><label for="speciallist">专家</label>
    </div>
    &lt;!&ndash;学校登录&ndash;&gt;
    <div class="list">
    &lt;!&ndash;<input type="radio" id="school" name="role">

    <span class="vir-check"><b>√</b></span>
    <label for="school">学校</label>&ndash;&gt;
    <span class="vir-check uncheck" id="school"></span><label for="school">学校</label>

    </div>-->

    <script type="text/javascript">
    /*登录控制*/
    var checks = document.getElementsByClassName('vir-check');
    var len = checks.length;
    var panel = document.getElementsByTagName('label');
    var form = document.getElementsByTagName('form')[0];
    var button = document.getElementById('login');
    var action1 = 'index.html';
    var action2 = 'login.html';
    var action3 = 'register.html';


    for(var j = 0;j<len;j++){


    checks[j].onclick = function(){


    if (this.innerHTML==""){

    //去掉其他项的勾选
    for(var h =0 ; h<len;h++){

    checks[h].innerHTML = "";
    }
    //把本项目的设为勾选
    this.innerHTML = "√";
    }
    }
    }

    for(var k = 0;k < len;k++){

    panel[k].onclick =function(){

    if (this.previousElementSibling.innerHTML == ""){

    //置空所有
    for(var l = 0; l<len ;l++){
    checks[l].innerHTML = "";
    }

    //选择相关项
    this.previousElementSibling.innerHTML = "√";

    /*修改跳转路径*/
    }
    }
    }


    button.onclick = function(){

    for(var f = 0;f<len;f++){
    if(checks[f].innerHTML=='√'){

    if(f==0){
    form.setAttribute('action',action1);
    }else if(f==1){
    form.setAttribute('action',action2);
    }else{
    form.setAttribute('action',action3);
    }
    form.submit();
    }
    }
    /*
    switch(f){
    case 0:

    form.submit();
    break;

    case 1:

    form.submit();
    break;

    case 2:


    break;
    default:
    console.log("没有弄对");
    }*/

    }

    </script>

  • 相关阅读:
    小程序与VUE请求后台接口,传数组
    VUE中使用Echarts图表
    封装一个VUE时间线组件
    Git的使用方法及IDEA与Git的集成(二)
    Git中拥有不同的仓库的不同账户
    IDEA无法集成Git问题
    IDEA之debug学习
    MyBatis 学习(三)
    MyBatis 学习(二)
    MyBatis 学习(一)
  • 原文地址:https://www.cnblogs.com/jameslong/p/3796779.html
Copyright © 2011-2022 走看看