JavaScript 및 Jquery 코드
6243 단어 JavaScriptjquerycss
document.onreadystatechange = function(){
if(document.readState == "complete"){
alert(" ," + document.radyState);
}
//do something
}
$(document).ready(function(){
alert("Jquery loaded") ;
//do something
});
//------------------------------------------
var textbox1 = document.getElementById("textbox1");
if(textbox1 != null && textbox1 != undefined){
alert(textbox1.value);
}
$("#TextBox1").val();
//------------------------------------------------------
var tb_list = document.getElementsByTagName("input");
for(var i=0; i< tb_list.length; i++){
alert(tb_list[i].name);
}
$("input").each(function(){
alert($(this).attr("name"));
})
//----------------------------------------------
var tb_list = document.getElementsByTagName("input");
for (var i=0;i<tb_list.length; i++){
if(tb_list[i].name.indexOf("TextBox") != -1){//indexOf
alert(tb_list[i].name);
}
}
$("input[name*=\"TextBox\"]").each(function(){
alert($(this).attr("name"));
})
//---------------------------------
var tb_list = document.getElementsByTagName("input");
for (var i=0;i<tb_list.length; i++){
if(tb_list[i].name.indexOf("TextBox") != -1){
tb_list[i].onclick = function(){
alert(this.name);
}
}
}
$("input[name*=\"TextBox\"]").click(function(){// name*=\"TextBox\"
alert($(this).attr("Name")); //attr("Name ")
})
//-----------------------------------------------
// checkbox
var cb_list = document.getElementsByName("input");
var checked = "5";
for(var i=0; i<cb_list.length; i++){
if(cb_list[i].type == "checkbox"){
cb_list[i].checked = true;
}
}
$("input[type=\"checkbox\"]").attr("checked",true);
//
$("input[type=\"checkbox\"]").each(function(){
$(this).attr("checked",true);
})
// checkbox true false
//--------------------------------------------------------------------------------
//
var tb_list = document.getElementsByTagName("input");
for(var i=0;i<tb_list.length;i++){
if(tb_list[i].name.indexOf("TextBox") != -1){
tb_list[i].style.width = "100";
tb_list[i].style.height = "30";
tb_list[i].style.border = "solid 1px red";
}
}
$("input[name*=\"TextBox\"]").each(function(){
$(this).css("height","30px").css("width","100px").css("border","solid 1px red");
//
$(this).css({height: "30px", width: "100px", border: "solid 1px red"});
//
$(this).height(30);
$(this).width(100);
$(this).css("border","solid 1px red");
})
//--------------------------------------------------------------------------------
//
var parent = document.getElementById("div1").getElementsByTagName("input");
for(var i=0;i<parent.length;i++){
parent[i].value = i;//0 1 2 3 4 5 6
}
$("#div1 > input").each(function(){
$(this).val(i);
})
//--------------------------------------------------------------------------------
// onmouseover onmouseout
var div_list = document.getElementById("divframe").getElementsByTagName("div");
for(var i=0;i<div_list.length;i++){
div_list[i].onmouseover = function(){
this.className = "f8";
};
div_list[i].onmouseout = function(){
this.className = "";
};
};
$("#divframe > div").mouseover(function(){
$(this).addClass("f8");
}).mouseout(function(){
$(this).removeClass("f8");
})
//--------------------------------------------------------------------------------
//
var tb_list = document.getElementsByTabName("input");
for(var i=0;i<tb_list.length;i++){
if(tb_list[i].type == "text"){
tb_list[i].disabled = true;//
tb_list[i].disabled = false;//
}
}
$("input[type=\"text\"]").attr("disabled",true);
$("input[type=\"text\"]").attr("disabled",false);
//---------------------------------------------------
var tb_list = document.getElementsByTagName("input");
for(var i=0;i<tb_list.length;i++){
if(tb_list[i].type == "text"){
tb_list[i].onkeyup=function(){
event.cancelBubble = true;
event.returnValue = false;
alert(event.keyCode);
}
}
}
$("input[type=\"text\"]").keyup(function(event){
event.cancelBubble = true;
event.returnValue = false;
alert(event.keyCode);
});
//--------------------------------------------------------------------------------
Attribute.indexOf(value);
//
Attribute
Attribute=value value
Attribute!=value value
Attribute^=value value
Attribute$=value value
Attribute*=value value
for example:
$("input[id][name$=\"4\"][type=\"text\"]").val("i");
:
1 input
2 id
3 name , name 4
4 type , type text
:
:i
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
기초 정리 - 1문자 (String) 숫자 (Number) 불린 (Boolean) null undefined 심볼 (Symbol) 큰정수 (BigInt) 따옴표로 묶어 있어야 함 Not-A-Number - 숫자 데이터 / 숫자로 표...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.