사용법:
먼저 머리에 있는 jQuery와 이 플러그인을 소개합니다
<script type="text/javascript" src="jquery-1.7.2.min.js">script> <script type="text/javascript" src="jquery.enplaceholder.js">script>
그럼 새를 부르시면 됩니다
//通过value模拟placeholder $('input').placeholder(); //通过插入元素模拟placeholder $('input').placeholder({isUseSpan:true});
코드:
<script type="text/javascript" src="/demo/js/jquery.min.js"></script><script type="text/javascript" src="/demo/js/38/jquery.enplaceholder.js"></script> <style type="text/css"> body { font: 12px/1.5 'simsun'; } form { width: 420px; height: 260px; margin: 20px auto 0; } h3 { font-weight: bold; margin: 10px 0; } p { margin-bottom: 10px; } input { vertical-align: middle; margin-left: 10px; height: 24px; line-height: 24px; width: 200px; padding-left: 2px; } textarea { vertical-align: middle; margin-left: 10px; width: 200px; height: 50px; font: inherit; padding-left: 2px; } .wrap-statistics { visibility: hidden; } html{color:#000;background:#fff;} body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,form,input,textarea,p,th,td,hr,button{margin:0;padding:0;} body,button,input,select,textarea{font:12px/1.5 tahoma,arial;} input,select,textarea{font-size:100%;} table{border-collapse:collapse;border-spacing:0;} th{text-align:inherit;} img{border:0;} iframe{display:block;} em,th{font-style:normal;font-weight:500;} ol,ul {list-style:none;} h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:500;} a{text-decoration:none;} a:hover{text-decoration:underline;} .fn-clear{zoom:1;} .fn-clear:after{visibility:hidden;display:block;font-size:0;content:".";clear:both;height:0;} .fn-hide{display:none;} .fn-left,.fn-right{display:inline;} .fn-left{float:left;} .fn-right{float:right;} .fn-hide-text{font-size:0;line-height:0;color:rgba(0,0,0,0);} .sl-wrap,.sl-wrap td,.sl-wrap th{word-wrap:break-word;word-break:break-all;} .sl-wrap-table{ table-layout:fixed; }</style> <form id="form1"> <h3 id="通过value方式模拟placeholder">通过value方式模拟placeholder</h3> <p>$('#form1 input,#form1 textarea').placeholder();</p> <p><label for="username1">用户名:</label> <input id="username1" name="username1" placeholder="请输入用户名" required="" type="text" value="" /></p> <p><label for="address1">地 址:</label> <input id="address1" name="address1" placeholder="请输入地址" required="" type="text" value="" /></p> <p><label for="remarks1">备 注:</label></p> </form> <form id="form2"> <h3 id="在不支持placeholder的浏览器下-通过插入悬浮的span元素方式模拟">在不支持placeholder的浏览器下,通过插入悬浮的span元素方式模拟</h3> <h4 id="文本框内容改变时placeholder消失">文本框内容改变时placeholder消失:</h4> <p>$('#username2,#password').placeholder({isUseSpan:true});</p> <p><label for="username2">用户名:</label> <input id="username2" name="username1" placeholder="请输入用户名" required="" type="text" value="" /></p> <p><label for="password">密 码:</label> <input id="password" name="password" placeholder="请输入密码" required="" type="password" value="" /></p> <p><label for="remarks2">备 注:</label></p> <h4 id="获得焦点时placeholder消失">获得焦点时placeholder消失:</h4> <p>$('#address2').placeholder({isUseSpan:true,onInput:false});</p> <p><label for="address2">地 址:</label> <input id="address2" name="address1" placeholder="请输入地址" required="" type="text" value="" /></p> </form> <script> $('#form1 input,#form1 textarea').placeholder(); $('#username2,#password').placeholder({isUseSpan:true}); $('#address2').placeholder({isUseSpan:true,onInput:false}); $('#remarks2').placeholder({isUseSpan:true}); </script>

实现方法:1、用“$("img").delay(毫秒数).fadeOut()”语句,delay()设置延迟秒数;2、用“setTimeout(function(){ $("img").hide(); },毫秒值);”语句,通过定时器来延迟。

区别:1、axios是一个异步请求框架,用于封装底层的XMLHttpRequest,而jquery是一个JavaScript库,只是顺便封装了dom操作;2、axios是基于承诺对象的,可以用承诺对象中的方法,而jquery不基于承诺对象。

修改方法:1、用css()设置新样式,语法“$(元素).css("min-height","新值")”;2、用attr(),通过设置style属性来添加新样式,语法“$(元素).attr("style","min-height:新值")”。

增加元素的方法:1、用append(),语法“$("body").append(新元素)”,可向body内部的末尾处增加元素;2、用prepend(),语法“$("body").prepend(新元素)”,可向body内部的开始处增加元素。

在jquery中,apply()方法用于改变this指向,使用另一个对象替换当前对象,是应用某一对象的一个方法,语法为“apply(thisobj,[argarray])”;参数argarray表示的是以数组的形式进行传递。

删除方法:1、用empty(),语法“$("div").empty();”,可删除所有子节点和内容;2、用children()和remove(),语法“$("div").children().remove();”,只删除子元素,不删除内容。

on()方法有4个参数:1、第一个参数不可省略,规定要从被选元素添加的一个或多个事件或命名空间;2、第二个参数可省略,规定元素的事件处理程序;3、第三个参数可省略,规定传递到函数的额外数据;4、第四个参数可省略,规定当事件发生时运行的函数。

去掉方法:1、用“$(selector).removeAttr("readonly")”语句删除readonly属性;2、用“$(selector).attr("readonly",false)”将readonly属性的值设置为false。


핫 AI 도구

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

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

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

Clothoff.io
AI 옷 제거제

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

인기 기사

뜨거운 도구

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

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

뜨거운 주제



