본문 바로가기

sundries

체크박스 선택 시 5초뒤 알람창으로 출력

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

<script src ="../js/jquery-3.2.1.js"></script>

</head>

<script>

$(function(){

setTimeout(function(){

var output='';

$('input:checked').each(function(index, item){

output += $(item).val()+' , ';

});

alert('선택한 스킬은'

+ output.substring(0,output.length-3)+ '입니다.');

},3000);

});

</script>

<body>

 스킬:

  <input type="checkbox" name="html" value="HTML" id="html" />

  <label for="html">HTML</label>

  <input type="checkbox" name="css" value="CSS" id="css" />

  <label for="css">CSS</label>

  <input type="checkbox" name="javascript" value="JavaScript" id="javascript" />

  <label for="javascript">JavaScript</label>

  <input type="checkbox" name="jsp" value="JSP" id="jsp" />

  <label for="jsp">JSP</label>

</body>

</html>







<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

<script src ="../js/jquery-3.2.1.js"></script>

</head>

<script>


$(function(){

var selecteSkill='';

$('input[type=checkbox]').click(function(){

selecteSkill += $(this).val() + ',';

});

setTimeout(function(){

alert('선택한 스킬은 ' + selecteSkill + '입니다');

}, 2000); 

});


</script>

<body>

스킬:

  <input type="checkbox" name="html" value="HTML" id="html" />  <label for="html">HTML</label>

  <input type="checkbox" name="css" value="CSS" id="css" />

  <label for="css">CSS</label>

  <input type="checkbox" name="javascript" value="JavaScript" id="javascript" />

  <label for="javascript">JavaScript</label>

  <input type="checkbox" name="jsp" value="JSP" id="jsp" />

  <label for="jsp">JSP</label>

</body>

</html>