본 글의 예시에서는 자바스크립트를 이용하여 정보를 추가, 삭제, 수정, 확인하는 방법을 설명합니다. 참고할 수 있도록 모든 사람과 공유하세요. 구체적인 구현 방법은 다음과 같습니다.
<body> <div align="center"> <h1 id="显示所有的用户界面">显示所有的用户界面</h1> <div style="border: 1px red solid; margin-bottom: 100px; padding: 10px 10%;"> <table border="1px" cellpadding="0" cellspacing="0" id="tusers"> <thead> <tr><th><input type="checkbox" name="chbk" id="chbk1" onclick="selectAll()"/></th> <th>名称</th> <th>性别</th> <th>邮箱</th> <th>出生日期</th> <th>操作</th> </tr> </thead> <tbody id="users"> </tbody> </table> <div id="pages"></div> </div> <div style="border: 1px blue solid;"> <form action=""> <table id="divs"> <tbody id="addUsers"> <tr> <td>用户名:</td> <td><input type="text" name="name" id="name"/></td> </tr> <tr> <td>性别:</td> <td><select id="sex"> <option value="男">男</option> <option value="女">女</option> </select> </td> </tr> <tr> <td>邮箱</td> <td><input type="text" name="email" id="email"/></td> </tr> <tr> <td>出生日期:</td> <td> <input type="text" id="bir" name="bir"/> <input type=button value="添加日期" onclick="showCalender(this,document.all.bir)"/> </td> </tr> <tr id="addu"> <td colspan="2"><input type="button" value="添加" onclick="addUser()" id="add"/></td> </tr> <tr id="addu1"> <td colspan="2"><input type="button" value="修改" id="upduser" /></td> </tr> </tbody> </table> </form> </div> </div> </body> <script> window.onload = function(){ alert("onload"); document.getElementById("addu1").style.display = "none"; } function selectAll(){ var users = document.getElementById("users"); var ips = users.getElementsByTagName("input"); var chbk = document.getElementById("chbk1"); for(var i=0;i<ips.length;i++){ ips[i].setAttribute("checked",chbk.getAttribute("checked")); } } function addUser(){ alert("add"); var name = document.getElementById("name").Value; var sex = document.getElementById("sex").Value; var email = document.getElementById("email").Value; var bir = document.getElementById("bir").Value; var tusers = document.getElementById("tusers").Value; var tr1 = document.createElement("tr"); var cbk = document.createElement("td"); var tname = document.createElement("td"); var tsex = document.createElement("td"); var temail = document.createElement("td"); var tbir = document.createElement("td"); var toper = document.createElement("td"); var cbk1 = document.createElement("input"); cbk1.setAttribute("type","checkbox"); cbk1.setAttribute("name","chbk"); cbk.appendChild(cbk1); tname.appendChild(document.createTextNode(name)); tsex.appendChild(document.createTextNode(sex)); temail.appendChild(document.createTextNode(email)); tbir.appendChild(document.createTextNode(bir)); var adelete = document.createElement("a"); var aupdate = document.createElement("a"); adelete.setAttribute("href","#"); aupdate.setAttribute("href","#"); adelete.appendChild(document.createTextNode("删除|")); aupdate.appendChild(document.createTextNode("修改")); toper.appendChild(adelete); toper.appendChild(aupdate); tr1.appendChild(cbk); tr1.appendChild(tname); tr1.appendChild(tsex); tr1.appendChild(temail); tr1.appendChild(tbir); tr1.appendChild(toper); var users = document.getElementById("users"); users.appendChild(tr1); tusers.appendChild(users); adelete.onclick = function(){ users.removeChild(adelete.parentNode.parentNode); } aupdate.onclick function(){ document.getElementById(addu).style.display = "none"; document.getElementById(addu1).style.display = "block"; var utr = aupdate.parentNode.parentNode; var utrs = utr.childNodes; document.getElementById("name").value = utrs[1].innerHTML; document.getElementById("sex").value = utrs[2].innerHTML; document.getElementById("email").value = utrs[3].innerHTML; document.getElementById("bir").value = utrs[4].innerHTML; var upUser = document.getElementById("upduser"); upUser.onclick = function(){ utr.childNodes[1].innerHTML = document.getElementById("name").value; utr.childNodes[2].innerHTML = document.getElementById("sex").value; utr.childNodes[3].innerHTML = document.getElementById("email").value; utr.childNodes[4].innerHTML = document.getElementById("bir").value; document.getElementById("addu1").style.display = "none"; document.getElementById("addu").style.display = "block"; } } testPage() } var indexPage = document.createElement("a"); var upPage = document.createElement("a"); var downPage = document.createElement("a"); var endPage = document.createElement("a"); var nowpage = 1; function testPage(){ var tbodyUsers = document.getElementById("users"); var trUsers = document.getElementById("tr"); var countRecord = trUsers.length; var PAGESIZE = 2; var countPage = (countRecord%PAGESIZE ==0?countRecord/PAGESIZE:Math.ceil(countRecord/PAGESIZE)); var pages=document.getElementById("pages"); if(!pages.hasChildNodes()){ getPages(nowpage); } index.onclik=function(){ noepage=1; indexPageInfo(countRecord,trUsers); } upPage.onclick=function(){ if(nowpage-1>1){ nowpage-=1; }else{ nowpage=1; indexPageInfo(countRecord,trUsers); } var startindex =(nowpage-1)*PAGESIZE; var endindex=startindex+PAGESIZE; PageInfo(startindex,endindex,countRecord,trUsers); } downPage.onclick=function(){ if(nowpage+1>=countPage){ nowpage=countPage; }else{ nowpage=+1; } var startindex =(nowpage-1)*PAGESIZE; var endindex=startindex+PAGESIZE; PageInfo(startindex,endindex,countRecord,trUsers); } endPage.onclick=function(){ if(nowpage>1){ var startindex =(nowpage-1)*PAGESIZE; for(var i=0;i<countRecord;i++){ if(i<startindex){ trUsers[i].style.display="none"; }else{ trUsers[i].style.display="block"; } } }else{ indexPageInfo(countRecord,trUsers); } } } function indexPageInfo(countRecord, trUsers) { if (countRecord <= 2) { for ( var i = 0; i < PAGESIZE; i++) { trUsers[i].style.display = "block"; } } else { for ( var i = 2; i < countRecord; i++) { trUsers[i].style.display = "none"; } } } function PageInfo(startindex, endindex, countRecord, trUsers) { for ( var i = 0; i < countRecord; i++) { if (i >= startindex && i < endindex) { trUsers[i].style.display = "block"; } else { trUsers[i].style.display = "none"; } } } function getPages(numpage) { indexPage.appendChild(document.createTextNode("首页")); indexPage.setAttribute("href", "#"); upPage.appendChild(document.createTextNode("上一页")); upPage.setAttribute("href", "#"); downPage.appendChild(document.createTextNode("下一页")); downPage.setAttribute("href", "#"); endPage.appendChild(document.createTextNode("末页")); endPage.setAttribute("href", "#"); var pages = document.getElementById("pages"); pages.appendChild(indexPage); pages.appendChild(upPage); pages.appendChild(downPage); pages.appendChild(endPage); } </script>
이 기사가 모든 사람의 JavaScript 프로그래밍 설계에 도움이 되기를 바랍니다.

去掉重复并排序的方法:1、使用“Array.from(new Set(arr))”或者“[…new Set(arr)]”语句,去掉数组中的重复元素,返回去重后的新数组;2、利用sort()对去重数组进行排序,语法“去重数组.sort()”。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于Symbol类型、隐藏属性及全局注册表的相关问题,包括了Symbol类型的描述、Symbol不会隐式转字符串等问题,下面一起来看一下,希望对大家有帮助。

怎么制作文字轮播与图片轮播?大家第一想到的是不是利用js,其实利用纯CSS也能实现文字轮播与图片轮播,下面来看看实现方法,希望对大家有所帮助!

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于对象的构造函数和new操作符,构造函数是所有对象的成员方法中,最早被调用的那个,下面一起来看一下吧,希望对大家有帮助。

方法:1、利用“点击元素对象.unbind("click");”方法,该方法可以移除被选元素的事件处理程序;2、利用“点击元素对象.off("click");”方法,该方法可以移除通过on()方法添加的事件处理程序。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于面向对象的相关问题,包括了属性描述符、数据描述符、存取描述符等等内容,下面一起来看一下,希望对大家有帮助。

foreach不是es6的方法。foreach是es3中一个遍历数组的方法,可以调用数组的每个元素,并将元素传给回调函数进行处理,语法“array.forEach(function(当前元素,索引,数组){...})”;该方法不处理空数组。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于BOM操作的相关问题,包括了window对象的常见事件、JavaScript执行机制等等相关内容,下面一起来看一下,希望对大家有帮助。


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

Dreamweaver Mac版
시각적 웹 개발 도구

안전한 시험 브라우저
안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

mPDF
mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.
