zoukankan      html  css  js  c++  java
  • 基础原生js

    给input元素赋值显示,用value:

     let enwenInput = document.getElementById("enwenTex");
     enwenInput .value = "apple";
    获取input元素填入的值:
    let enwen = document.getElementById("enwenText").value;
     
    获取selection标签选中的值:
    let cixingSel = document.getElementById("wordClassSelect");
    let cixing = cixingSel.options[cixingSel.selectedIndex].value;
    获取selection标签下的所有option:

    var obj=document.getElementById('mySelect');
    var items=document.getElementById("sect").options;

    设置selection标签选中的项:

    var obj=document.getElementById('mySelect');

     obj.selectedIndex = 3;
     
    给td标签,a标签,lable标签赋值显示,用innerHTML :
    let td1 = document.createElement("td");
    td1.innerHTML = wordList[i].english;
     
    元素添加点击事件:
    (1)直接加在属性上
    <button onclick="updateWord()">
                            确 认
     </button>
    (2)js添加
    let elea = document.createElement("a");
    elea.setAttribute("href", "#");
    elea.setAttribute("id",  wordList[i].id);
    elea.innerHTML = '编辑';
    elea.onclick  = editFun;
    function editFun(){}
     
    点击后弹出确认框:
    <button onclick="updateWord()">
                            确 认
     </button>
    function updateWord{
      
      var res = confirm("确定删除该条记录吗?");
                if(res){
                    alert("删除成功!");
                    window.location.reload();
                }
    }
  • 相关阅读:
    Python基础闯关失败总结
    fileinput
    squid安装配置
    服务器添加ipa MIME 类型,防止ipa下载后变zip后缀
    单例之懒汉式和饿汉式
    java集合类,详解
    Android 常用动画
    activity和fragment之前运行的生命周期
    Handler 消息传递机制
    startActivityForResult的用法,以及intent传递图片
  • 原文地址:https://www.cnblogs.com/maycpou/p/13845490.html
Copyright © 2011-2022 走看看