forEach <-배열.객체랑 같이
ar=[1,2,3,4]
ar.forEach(function(a1){
console.log(a1);
}
Use $ instead of jQuery
jquery
$.each(ar,function(index,value){
console.log(value);
});
('table tr').each(function(ndx,str){ str=(this).find('td:eq(0)').text();
console.log(str);
});
ar=[1,2,3,4]
.inArray(7,ar); // n=-1
$.isArray(7,ar) // n=false
isNaN(is Not a Number) 숫자가 아닌 것을 골라낸다
a='24';
b=isNaN(a); // b=false; //숫자이다
a='a2';
b=isNaN(a); // b=true; //숫자가 아니다 (사용할 때 헷갈리지 않게 주의)
a가 숫자로만 이루어져 있는가?
'a2' >>> false
24 >>> true
var dt = new Date();
var dt = $.now();
calling a method : get or post
$(document) is an object
$(document)
.ready(function(){
// As webpage loading ends, execute this function first. (reset part)
특정 tr 위에 마우스를 대면 빨간색이 되고 다른 tr에 마우스가 올라가면 원래 색으로 돌아오는 코드를 짜라
Code 1.
Code 2.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<table border=1>
</table><br><br>
<table>
<tr>
<td> </td><td> </td><td> </td>
</tr>
<tr>
<td> </td><td> </td><td> </td>
</tr>
<tr>
<td> </td><td> </td><td> </td>
</tr>
<tr>
<td> </td><td> </td><td> </td>
</tr>
<tr>
<td> </td><td> </td><td> </td>
</tr>
<tr>
<td> </td><td> </td><td> </td>
</tr>
<tr>
<td> </td><td> </td><td> </td>
</tr>
<tr>
<td> </td><td> </td><td> </td>
</tr>
</table>
</body>
<script src="http://code.jquery.com/jquery-3.5.0.js">
</script>
<script language="javascript">
var ndx=-1;
var bgColor=null;
$(document)
.ready(function(){
$('table tr:even').css('background-color','yellow');
$('table tr:odd').css('background-color','blue');
})
.on('mouseover','tr',function(){
if(ndx>-1){
$('table tr:eq('+ndx+')').css('background-color',bgColor)
//restore
}
ndx=$(this).index(); //current index
bgColor=$(this).css('background-color'); //current color
$(this).css('background-color','red');
})
</script>
</html>
remove blanks in String
THe number of elements in jQuery
$('select').length
how many select
in this document
$('input[type=rado][name=gender]').is(':checked')
without coma
.on('click','div',function(){
})
.on('click','table',function(){
})
.on('click','#female',function(){
})
== .on('click','div, table, #female',function(){
})
immediately following sibeling
//table
//tr td 123 /td td 456 /td
opposite to .prev()
$(x).replaceWith(y) >>> replace x to y (change the whole tag)
oppoiste to hide()