1) 버튼을 눌렀을 때 입력한 글자로 alert 띄우기
function q1() {
let txt = $('#input-q1').val();
if (txt == '') {
alert('입력하세요!')
} else {
alert(txt)
}
}
2) 이메일 판별해 도메인 alert 띄우기
function q2() {
let txt = $('#input-q2').val();
console.log(txt.includes("@"))
if (txt.includes("@")) {
let domain = txt.split('@')[1].split('.')[0]
alert(domain)
} else {
alert('이메일이 아닙니다.')
}
}
3) 이름 붙이고, 지우기
function q3() {
let txt = $('#input-q3').val();
let temp_html = <li>${txt}</li>
$('#names-q3).append(temp_html)
}
function q3_remove() {
$('#names-q3').empty()
}
차근차근히 풀어나가는게 중요!
중간중간 console.log()로 확인하기!