javascript转换成jquery代码
functionpasswd(){varpass=document.getElementById("psd").value;vartip=document.getElem...
function passwd(){
var pass = document.getElementById("psd").value;
var tip = document.getElementById("tip");
if (pass.length < 4) {
document.getElementById("meter").value = pass.length;
tip.innerHTML = "差";
}
else
if (pass.length <= 8) {
document.getElementById("meter").value = pass.length;
tip.innerHTML = "中";
}
else {
document.getElementById("meter").value = pass.length;
tip.innerHTML = "高";
}
}
function repasswd(){
var passwd1 = document.getElementById("psd").value;
var passwd2 = document.getElementById("psd2").value;
if (passwd1 == passwd2){
tip8.innerHTML = "输入正确!";
}
else {
tip8.innerHTML = "输入错误,请重新输入!";
}
} 展开
var pass = document.getElementById("psd").value;
var tip = document.getElementById("tip");
if (pass.length < 4) {
document.getElementById("meter").value = pass.length;
tip.innerHTML = "差";
}
else
if (pass.length <= 8) {
document.getElementById("meter").value = pass.length;
tip.innerHTML = "中";
}
else {
document.getElementById("meter").value = pass.length;
tip.innerHTML = "高";
}
}
function repasswd(){
var passwd1 = document.getElementById("psd").value;
var passwd2 = document.getElementById("psd2").value;
if (passwd1 == passwd2){
tip8.innerHTML = "输入正确!";
}
else {
tip8.innerHTML = "输入错误,请重新输入!";
}
} 展开
1个回答
展开全部
function passwd(){
var pass = $("#psd").val();
var tip = $("#tip");
if (pass.length < 4) {
$("#meter").val(pass.length) ;
tip.html("差");
}
else
if (pass.length <= 8) {
$("#meter").val(pass.length) ;
tip.html("中");
}
else {
$("#meter").val(pass.length);
tip.html("高");
}
}
function repasswd(){
//通过$("#id");方式获取赋值给tip8
var passwd1 = $("#psd").val();
var passwd2 = $("#psd2").val();
if (passwd1 == passwd2){
tip8.html("输入正确!");
}
else {
tip8.html( "输入错误,请重新输入!");
}
}
var pass = $("#psd").val();
var tip = $("#tip");
if (pass.length < 4) {
$("#meter").val(pass.length) ;
tip.html("差");
}
else
if (pass.length <= 8) {
$("#meter").val(pass.length) ;
tip.html("中");
}
else {
$("#meter").val(pass.length);
tip.html("高");
}
}
function repasswd(){
//通过$("#id");方式获取赋值给tip8
var passwd1 = $("#psd").val();
var passwd2 = $("#psd2").val();
if (passwd1 == passwd2){
tip8.html("输入正确!");
}
else {
tip8.html( "输入错误,请重新输入!");
}
}
追问
在么,请问相应的html文件里的语句怎么改呢。我只会js,原先调用这个js文件是通过onkeyup="passwd()"与onkeyup="repasswd()"触发的
追答
首先引入jquery,然来的页面onkeyup="passwd()"与onkeyup="repasswd()"去掉
然后 script里面写 $(document).ready(function(){
//id为输入框的id
$("#psd").change(function(){//第一次输入密码的框
var pass = $(this).val();
var tip = $("#tip");
if (pass.length < 4) {
$("#meter").val(pass.length) ;
tip.html("差");
}
else
if (pass.length <= 8) {
$("#meter").val(pass.length) ;
tip.html("中");
}
else {
$("#meter").val(pass.length);
tip.html("高");
}
});
$("#psd2").change(function(){//第二次输入密码的框
//通过$("#id");方式获取赋值给tip8
var passwd1 = $("#psd").val();
var passwd2 = $(this).val();
if (passwd1 == passwd2){
tip8.html("输入正确!");
}
else {
tip8.html( "输入错误,请重新输入!");
}
});
});
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询