jQuery
javascript - library
dom ๊ด๋ จ๋ ๋ด์ฉ ์ฒ๋ฆฌ
https://api.jquery.com/ or https://www.w3schools.com/jquery/jquery_selectors.asp
์ฌ์ดํธ ์ฐธ์กฐ
1. selector <-- css
2. ์ฒ๋ฆฌ์ฉ ๋ฉ์๋
1 . ๋ฐฐ์ด
2.
for.each๋ง๊ณ ๋ map()- ๋ด์ฉ๋ณ๊ฒฝ / filter() - ๋ด์ฉ๊ฒ์ ๋ฑ์ ๊ธฐ๋ฅ์ด ๋ ์๋ค.
๋ด์ฉ์ ๊ฒ์ํ์ฌ ์ ์ฉ์์ผ์ค๋ค.
1.
$('h2').filter(':even').css('color', 'coral'); <-- h2 ์ค ์ง์๋ฒ ์ฐพ์์ ์ ๋ณ๊ฒฝ
2.
//$('h2').filter(':even').css({
//color: 'coral',
//backgroundColor : 'yellow' <-- ๊ฐ์ฒดํ์์ผ๋ก ๋ฐฐ๊ฒฝ๊ณผ ํจ๊ป ์ค๋ ๋จ
//});
3.
//const h2 = $('h2'); //htmlcollection, ๋ฐฐ์ด๊ณผ ๋น์ท
//console.log(h2);
//h2.filler(':even').css('color', 'coral'); <--- ๋ณ์ ์ ์ธ ํ ์ ๊ธฐ
----------------------
<h2>Header - 1</h2>
<h2>Header - 2</h2>
<h2>Header - 3</h2>
<h2>Header - 4</h2>
<h2>Header - 5</h2>
<script type="text/javascript">
$( document ).ready( function() {
$('h2').filter( function() {
console.log('h2');
});
});
</script>
each์ ๋๊ฐ์ด ๋ด๋ถ์ ์ผ๋ก ๋ฃจํ๋ฅผ ๋๊ณ ์๋ค๊ณ ๋ณด๋ฉด ๋๋ค.
$( document ).ready( function() {
$('h2').filter( function(index) {
// true / false
return index % 2 == 0; <--- index๊ฐ ์ง์์ผ ๋
}).css('color', 'coral'); <--- ์ ๋ณ๊ฒฝํ๊ฒ ๋ค.
});
๋ฐ๋ผ์ ์ธ๋ฑ์ค๊ฐ ์ง์์ธ ๊ฒ๋ง ์ ๋ณ๊ฒฝํ๋ 'ํํฐ์ ๋ด์ฉ์ ๋ง๋ค์ด์ค ์ ์๋ค.'
$('h2').css('background-color', 'lightcoral');
$('h2').filter(':even').css('color', 'blue');
$('h2').filter(':odd').css('color', 'white');
$('h2').css('background-color', 'lightcoral')
.filter(':even').css('color', 'blue')
.filter(':odd').css('color', 'white'); //even ์ค์ odd๊ฐ ์ ์ฉ๋๋ ๊ฒ์
.์ ์ด์ฉํ์ฌ ํ ๋ฒ์ ์ฐ๊ฒฐํด์ ์์ ๊ฐ์ด ์ฐ๋ ค๊ณ ํ์ผ๋ odd๊ฐ filter์ filter๋ก ์ ์ฉ๋์ด even ์ค์์ odd๊ฐ ๋ณ๊ฒฝ๋๋๋ก ์ ์ฉ์ด ๋จ(1, 3, 5 ์ค์ ์ง์๋ 2๋ฒ์งธ์ธ 3)
$('h2').css('background-color', 'lightcoral')
.filter(':even').css('color', 'blue')
.end() //filter ์ ์ฉ๋ ๊ฒ์ด ์ทจ์๋์ด ๋ฐ ํํฐ๊ฐ ๋งจ ์ฒ์ ๊ฒ์ ๋ง๊ฒ ์ ์ฉ
.filter(':odd').css('color', 'white');
end๋ฅผ ์ฌ์ฉํ์ฌ filter ์ ์ฉ์ ์ทจ์ ์์ผ ๊ทธ ์ดํ์ ๋์ค๋ filter๊ฐ ๋งจ ์์์ filter ํ๋๋ก ์ ์ฉ์์ผ์ค๋ค. ( ๊ฒฐ๊ณผ ์ฒ์๊ณผ ๋์ผ )
//$('h1').css('background-color', 'coral');
//$('h1, h2').css('color', 'blue');
$('h1').css('background-color', 'coral')
.add('h2').css('color', 'blue'); (.add๋ก h1์์ ์ถ๊ฐ๋ก h2๋ ๊ธ์์ ๋ฐ๊พผ๋ค๋ ๋ป)
(๊ฒฐ๊ณผ๋ ์์ ๋์ผ)
h1 ์ ์ฉ์ ํฌํจํด์ h2 ์ ์ฉํ๋ ๊ฒ
1.
console.log($(document).find('h2')); <-- h2ํ๊ทธ๋ฅผ ๊ฒ์ํด์ค
2.
$(document).find('h2').each(function(index, item) {
console.log(index, ':', item.innerHTML); <--- each๋ก ๋ฃจํ๋๋ ค์ ๊ฒ์๋ ๊ฒฐ๊ณผ์ ๋ด์ฉ๋ง ๊ฐ์ ธ์ด
3.
$(document).find('.c').each(function(index, item) { <--- class="c"์ธ ๊ฒ ๊ฒ์
console.log(index, ':', this.innerHTML);
});
xml ํ์ ๋ณ์ ํ๋ ์ ๋นํ๊ฒ ๋ง๋ค๊ธฐ
const xml = `<friends>
<friend>
<name>tester1</name>
<language>Javascript</language>
</friend>
<friend>
<name>tester2</name>
<language>Java</language>
</friend>
<friend>
<name>tester3</name>
<language>Python</language>
</friend>
</friends>
`;
ํ์ฌ๋ string ํ์์ด๋ค.
ํ์ ๋ณ๊ฒฝ
$( document ).ready( function() {
console.log(typeof xml);
const xmlDoc = $.parseXML(xml); // xml Domํ ์ํด
console.log(typeof xmlDoc);
});
string - > object๋ก ๋ฐ๊ฟ
find ์ ์ฉ
$(xmlDoc).find('friend').each(function(index, item) {
console.log(index);
console.log($(item).find('name')[0].innerHTML); <--name๋ง ๋ฝ๊ธฐ
});
$('h2').each(function() {
// is : ์์ selector ์กด์ฌ ์ฌ๋ถ ๊ฒ์
if($(this).is('.c')) {
$(this).css('color', 'coral');
}
});
$( document ).ready( function() {
// json
let object = {name: "ํ๊ธธ๋"};
console.log(object);
1.
//๋์ ์ผ๋ก ํ๋กํผํฐ ์ถ๊ฐ ๊ฐ๋ฅ
object.region1 = '์์ธ์ ์ข
๋ก๊ตฌ';
object.part1 = '๋ฆฌ๋';
console.log(object);
});
2. ๊ฐ์ฒด์ ๋ํ ํ์ฅ (์์ ๋์ผํ๊ฒ ๊ฐ์ฒด๊ฐ ์ถ๊ฐ๋จ)
$.extend(object, {region2: '์์ธ์ ๊ฐ๋จ๊ตฌ', part2: '๋ฒ ์ด์ค'});
$.extend(object, {region3: '์์ธ์ ์์ด๊ตฌ', part3: '์ธ์ปจ๋'});
console.log(object);
$.noConflict(); <-- $ ์ถฉ๋๋จ์ ๋ฐฉ์งํ๊ธฐ ์ํ์ฌ ์ฌ์ฉ ์ํ๋ค๋ ๋ป
$.noConflict();
const J = jQuery;
//$( document ).ready( function() {
J( document ).ready( function() {
console.log("Hello jQuery");
});
์ extend ์ฝ๋ ๋ณ๊ฒฝํด๋ณด๊ธฐ
$.noConflict();
const J = jQuery;
//$( document ).ready( function() {
J( document ).ready( function() {
let object = {name: "ํ๊ธธ๋"};
J.extend(object, {region2: '์์ธ์ ๊ฐ๋จ๊ตฌ', part2: '๋ฒ ์ด์ค'});
J.extend(object, {region3: '์์ธ์ ์์ด๊ตฌ', part3: '์ธ์ปจ๋'});
console.log(object);
});
๊ธฐ๋ณธ์ ์ผ๋ก ์ฌ์ฉ ๋ณ๊ฒฝ
innerHTML ==> html();
textContent ==> text();
1. ๋ด์ฉ ํ์ธ ๋ฒํผ ๋๋ฅผ ์
$( document ).ready( function() {
//innerHTML ==> html();
//textContent ==> text();
document.getElementById('btn1').onclick = function() {
//javascript ๋ฐฉ์
const html = document.getElementById('result');
console.log(html.innerHTML);
console.log(html.textContent);
};
});
// jQuery ๋ฐฉ์
console.log($('#result').html());
console.log($('#result').text());
-------------------------------------------------------------
2. ๋ด์ฉ ์์ ๋ฒํผ ๋๋ฅผ ์
document.getElementById('btn2').onclick = function() {
//javascript ๋ฐฉ์
//const html = document.getElementById('result');
//html.innerHTML = '<i>์๋ก์ด ๊ฒฐ๊ณผ</i>';
//html.textContent = '<i>์๋ก์ด ๊ฒฐ๊ณผ</i>';
// jQuery
console.log($('#result').html('<i>์๋ก์ด ๊ฒฐ๊ณผ</i>'));
//console.log($('#result').text('<i>์๋ก์ด ๊ฒฐ๊ณผ</i>');
};
--------------------------------------------------------------
<body>
<button id="btn1">๋ด์ฉ ํ์ธ</button>
<button id="btn2">๋ด์ฉ ์์ </button>
<br><hr><br>
<div id="result"><b>์ถ๋ ฅ ๋ด์ฉ</b></div>
</body>
<script type="text/javascript">
$( document ).ready( function() {
document.getElementById('btn1').onclick = function() {
// 1. ์งํฉ์ ์ ์ฉ
//$('div').html('<i>์๋ก์ด ๊ฒฐ๊ณผ</i>');
//2. ๋ถ๋ฆฌ์
$('div').html( function(index) {
return '<i>์๋ก์ด ๊ฒฐ๊ณผ ' + index + '</i>'
})
};
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script type="text/javascript">
$( document ).ready( function() {
document.getElementById('btn').onclick = function() {
const sDan = $('#startdan').val();
const eDan = $('#enddan').val();
const iStartDan = parseInt(sDan);
const iEndDan = parseInt(eDan);
let html = '<table border="1" width="800">';
for(let i = iStartDan; i <=iEndDan; i++) {
html += '<tr>';
for(let j = 1; j <=9; j++) {
html += '<td>' + i + 'x' + j + '=' + (i*j) + '</td>';
}
html += '</tr>';
}
html += '</table>';
$('#result').html( html );
};
});
</script>
</head>
<body>
์์๋จ <input type="text" id="startdan" />
~
๋๋จ <input type="text" id="enddan" />
<button id="btn">๊ตฌ๊ตฌ๋จ ์ถ๋ ฅ</button>
<br><hr><br>
<div id="result"></div>
</body>
$(document).ready(function() {
document.getElementById('btn').onclick = function() {
// $('ํ๊ทธ') - selector
// $('html ๋ด์ฉ') - ์์ฑ
// appendTo ๋ถ์ด๋ ๊ฒ. / prependTo / insertAfter / insertBefore
$( '<i>Hello jQuery</i>' ).appendTo('#result');
$('<i></i>').html('Hello jQuery').prependTo('#result');
}
});
<script type="text/javascript">
$( document ).ready( function() {
1.
//๋ด์ฉ์ญ์
document.getElementById('btn1').onclick = function() {
$('#d').html('');
};
2.
//๋ด์ฉ์ญ์
document.getElementById('btn2').onclick = function() {
$('#d').empty();
};
3.
//ํ๊ทธ์ญ์
document.getElementById('btn3').onclick = function() {
$('#d').remove(); //divํ๊ทธ ์ ์ฒด๊ฐ ์ญ์ ๋จ
};
4.
document.getElementById('btn4').onclick = function() {
$('P').first().remove(); //์ฒซ๋ฒ์งธ ๊ฒ๋ง ์ง์
};
});
</script>
---------------------------------------------------------------
</head>
<body>
<button id="btn1">๋ด์ฉ ์ญ์ </button>
<button id="btn2">๋ด์ฉ ์ญ์ </button>
<button id="btn3">๋ด์ฉ ์ญ์ </button>
<button id="btn4">๋ด์ฉ ์ญ์ </button>
<br><hr><br>
<div id="d">
<p>๋ด์ฉ 1</p>
<p>๋ด์ฉ 2</p>
</div>
</body>
1,2.
<script type="text/javascript">
$( document ).ready( function() {
document.getElementById('btn1').onclick = function() {
//1๊ฐ๋ง ์ถ๋ ฅ๋จ
//console.log($('img').attr('src'));
1.
$('img').each( function(index, item) {
console.log($(item).attr('src'));
}); // attr -> attribute
2.
$('img').attr('src', function(index, item) {
console.log(item);
})
}
});
</script>
1,2 ๊ฒฐ๊ณผ๋ ๋์ผ
-------------------------------------------------------
<body>
<button id="btn1">์์ฑ ๋ด์ฉ</button>
<br><hr><br>
<img src="./images1/Chrysanthemum.jpg" width="150" />
<img src="./images1/Desert.jpg" width="150" />
<img src="./images1/Hydrangeas.jpg" width="150" />
<img src="./images1/Jellyfish.jpg" width="150" />
</body>
1. ์๊น์ ๋ค๋ฅด๊ฒ ์ ์ฒด ๋ค ์ ์ฉ๋๋ค.
document.getElementById('btn2').onclick = function() {
$('img').attr('width', 100);
}
2. ์ ์ฒด ๋ค ์ ์ฉ + ๊ฐ์ ๋ค๋ฅธ ํฌ๊ธฐ(ํฌ๊ธฐ๊ฐ 100์ฉ ์ฆ๊ฐํจ)
document.getElementById('btn2').onclick = function() {
$('img').attr('width', function(index) {
return (index + 1) * 100;
});
3. width + height ์ฃผ๊ธฐ
document.getElementById('btn2').onclick = function() {
$('img').attr( {
width: 100,
height: 200
});
};
4. 2๋ฒ ํ์ฅ
document.getElementById('btn2').onclick = function() {
$('img').attr( {
width: function(index) {
return (index + 1) * 100;
},
height: 200
});
};
document.getElementById('btn3').onclick = function() {
$('img').removeAttr('height'); <--- ์ฃผ์ด์ง ๋์ด ๊ธธ์ด ์ญ์
}
src, id ๋ฑ ๊ธฐ์กด ์์ฑ ๋ง๊ณ ์ฌ์ฉ์๊ฐ ์ง์ ๋ง๋ค์ด์ ๋์ ํ ์ ์๋ค.
<img src="./images1/Chrysanthemum.jpg" width="150" data="1" />
<img src="./images1/Desert.jpg" width="150" data="2" />
<img src="./images1/Hydrangeas.jpg" width="150" data="3"/>
<img src="./images1/Jellyfish.jpg" width="150" data="4"/> <-- data๋ผ๋ ์์ฑ ๊ฐ๊ฐ ๋ถ์ฌ
$('img').each( function(index, item) {
console.log($(item).attr('data')); <--- ๋ง๋ ์์ฑ์ผ๋ก ์ถ๋ ฅ
});
$( document ).ready( function() {
document.getElementById('btn1').onclick = function() {
1. ๊ธฐ๋ณธ์ผ๋ก ์ฌ์ฉํ๋ ๊ฒ
//console.log(document.frm.data.value);
2. jQuery
console.log($(#data).val());
3. ๋ฐ์ดํฐ๊ฐ ๋ฃ๊ธฐ
document.getElementById('btn2').onclick = function() {
$('#data').val('์๋ก์ด ๋ฐ์ดํฐ');
};
});
------------------------------------------------------------------------
<body>
<button id="btn1">๋ด์ฉ</button>
<button id="btn2">๋ด์ฉ ์ถ๊ฐ</button>
<br><hr><br>
<form name="frm">
๋ฐ์ดํฐ <input type="text" name="data" id="data" />
</form>
</body>
1,2.
$( document ).ready( function() {
document.getElementById('btn1').onclick = function() {
//console.log(document.frm.data.value);
$('input:checkbox:checked').each( function() {
console.log($(this).val());
});
};
});
-------------------------------------------------------------
<body>
<button id="btn1">๋ด์ฉ</button>
<br><hr><br>
<form name="frm">
<input type="checkbox" id="ch1" name="ch" value="์๋ฐ">์๋ฐ<br>
<input type="checkbox" id="ch2" name="ch" value="๋ธ๊ธฐ">๋ธ๊ธฐ<br>
<input type="checkbox" id="ch3" name="ch" value="์ฌ๊ณผ">์ฌ๊ณผ<br>
<input type="checkbox" id="ch4" name="ch" value="์๋ชฝ">์๋ชฝ<br>
</form>
</body>
select
$( document ).ready( function() {
document.getElementById('btn1').onclick = function() {
//console.log(document.frm.data.value);
$('input:checkbox:checked').each( function() {
//checkbox
console.log($(this).val());
});
//select
console.log('select :', $('#sel option:selected').val());
};
});
</script>
</head>
<body>
<button id="btn1">๋ด์ฉ</button>
<br><hr><br>
<form name="frm">
<input type="checkbox" id="ch1" name="ch" value="์๋ฐ">์๋ฐ<br>
<input type="checkbox" id="ch2" name="ch" value="๋ธ๊ธฐ">๋ธ๊ธฐ<br>
<input type="checkbox" id="ch3" name="ch" value="์ฌ๊ณผ">์ฌ๊ณผ<br>
<input type="checkbox" id="ch4" name="ch" value="์๋ชฝ">์๋ชฝ<br>
<br>
<select id="sel">
<option value="์ฌ๊ณผ">์ฌ๊ณผ</option>
<option value="์๋ชฝ">์๋ชฝ</option>
<option value="๋ธ๊ธฐ">๋ธ๊ธฐ</option>
<option value="๋ฉ๋ก ">๋ฉ๋ก </option>
</select>
</form>
<style type="text/css">
.c1 { color: coral; }
.c2 { color: pink; }
.c3 { color: red; }
</style>
-----------------------------
<script type="text/javascript">
$( document ).ready( function() {
document.getElementById('btn1').onclick = function() {
1. ํ๋์ ์ ๋ณด๋ง ๊ฐ์ ธ์ด
console.log($('h2').css('color')); //css ์ค์ ํ color์
2. ๋ค ๊ฐ์ ธ์ด(each)
$('h2').css('color', function(index, item) {
console.log(item);
})
}
});
</script>
-----------------------------
<body>
<button id="btn1">๋ด์ฉ</button>
<br><hr><br>
<h2 class="c1">header-1</h2>
<h2 class="c2">header-2</h2>
<h2 class="c3">header-3</h2>
</body>
1. ์ ๋ถ ๋ค ๋ณ๊ฒฝ
document.getElementById('btn2').onclick = function() {
$('h2').css('color', 'cyan');
};
2. ๊ฐ๊ฐ ์์ ์ค์ ๋ณ๊ฒฝ
document.getElementById('btn2').onclick = function() {
//$('h2').css('color', 'cyan');
const colors = ['purple', 'black', 'aqua']; //๊ฐ๊ฐ ์์๋๋ก ๋ค์ด๊ฐ
$('h2').css('color', function(index){
return colors[index];
});
};
------------------------------------------
<button id="btn2">๋ณ๊ฒฝ</button>
<script type="text/javascript">
$( document ).ready( function() {
1. ํด๋์ค ์ถ๊ฐ
document.getElementById('btn1').onclick = function() {
$('h2').addClass('c');
};
2. ํด๋์ค ์ญ์
document.getElementById('btn2').onclick = function() {
$('h2').removeClass('c');
};
3. ํ ๊ธ(๊ป๋ค ์ผฐ๋ค ํ๊ธฐ)
document.getElementById('btn2').onclick = function() {
$('h2').toggleClass('c');
};
});
</script>
-----------------------------------------------------------------
<body>
<button id="btn1">๋ด์ฉ</button>
<button id="btn2">๋ณ๊ฒฝ</button>
<button id="btn3">ํ ๊ธ</button>
<br><hr><br>
<h2 >header-1</h2>
<h2 >header-2</h2>
<h2>header-3</h2>
</body>
์ด๋ฒคํธ ์ฌ์ฉ ๋ฐฉ๋ฒ
1.
$('์ด๋ฒคํธ ๋์').on('์ด๋ฒคํธ', function() {
์ฒ๋ฆฌ
});
2.
$('์ด๋ฒคํธ ๋์').์ด๋ฒคํธ(function() {
์ฒ๋ฆฌ
});
1. ๋ฒํผ ํด๋ฆญ
$( document ).ready( function() {
$('#btn1').click(function() {
alert('btn1 ํด๋ฆญ');
});
2. ๋ฒํผ์ ๋ง์ฐ์ค๋ฅผ ๋์ ์ฒ๋ฆฌ๋จ
$('#btn2').mouseover(function() {
alert('btn2 ์ฒ๋ฆฌ');
});
3. ๋ฒํผ ํด๋ฆญ2
$('#btn3').on( 'click', function() {
alert('btn3 ํด๋ฆญ');
});
4.์ด๋ฒคํธ ํตํฉ ์ถ๋ ฅ
$('#btn2').on('click mouseover mouseleave', function() {
console.log('btn2 ๋ง์ฐ์ค ์ด๋ฒคํธ'); <-- ๋ญ ํ๋ ์ด๊ฒ ์ถ๋ ฅ
});
4-1. ์ฌ์ฉํ ์ด๋ฒคํธ ๋ณ๋ก ๋ฐ๋ก ์ฝ์์ ์ถ๋ ฅ
$('#btn2').on({
'click':function() {
console.log('click');
},
mouseover :function() {
console.log('mouseover');
},
mouseleave: :function() {
console.log('mouseleave');
},
}
});
1,3.
๋ฒํผ ํด๋ฆญ
1. ๊ฐ๊ฐ ํด๋ฆญ๊ฐ ๋ค๋ฅด๊ฒ ํ๊ธฐ
$( document ).ready( function() {
$('button').on('click', function() {
alert('๋ฒํผ ํด๋ฆญ : ' + $(this).attr('id'));
});
});
--------------------------------------
<body>
<button id="btn1">๋ฒํผ 1</button>
<button id="btn2">๋ฒํผ 2</button>
<button id="btn3">๋ฒํผ 3</button>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script type="text/javascript">
// ready == window.onload
$( document ).ready( function() {
$('#btn1').on('click', function() {
$.ajax({
url: './data/csv1.jsp',
type: 'get',
dataType: 'text',
success: function(csvData) {
console.log('์ฑ๊ณต', typeof csvData);
console.log('์ฑ๊ณต', csvData);
},
error: function(err) {
console.log('์คํจ', err.status);
console.log('์คํจ', err.responseText);
}
})
});
});
</script>
------------------------------------------------------------------
<body>
<button id="btn1">์์ฒญ</button>
<br><hr><br>
</body>
์ ์ฝ๋์์ url, dataType ๋ง ๋ณ๊ฒฝ
url: './data/xml1.jsp',
dataType: 'xml',
url: './data/json1.jsp',
dataType: 'json',
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script type="text/javascript">
// ready == window.onload
$( document ).ready( function() {
$('#btn1').on('click', function() {
$.ajax({
url: './data/xml1.jsp',
type: 'get',
dataType: 'xml', //์ด๊ฒ์ ๋ฐ๋ผ ๋ฐ์ดํฐ ํ์
์ด ๋ฐ๋ผ๊ฐ
success: function(xmlData) {
let html = '<table border="1" width="800">';
$(xmlData).find('book').each(function() {
html += '<tr>';
html += '<td>' + $(this).find('name').text() + '</td>';
html += '<td>' + $(this).find('publisher').text() + '</td>';
html += '<td>' + $(this).find('author').text() + '</td>';
html += '<td>' + $(this).find('price').text() + '</td>';
html += '</tr>';
});
html += '</table>';
$('#result').html(html);
},
error: function(err) {
console.log('์คํจ', err.status);
console.log('์คํจ', err.responseText);
}
})
});
});
</script>
</head>
<body>
<button id="btn1">์์ฒญ</button>
<br><hr><br>
<div id="result"></div>
</body>
</html>