답변 7개
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>라디오 버튼 포커스 테스트</title>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
function send_go() {
console.log("send_go called");
// 첫 번째 라디오 버튼 체크 + 포커스
$('#send_type1').prop("checked", true).focus();
// 시각적으로 확인 가능하게 alert도 추가
alert("첫 번째 라디오 버튼에 체크 및 포커스 됨");
}
</script>
</head>
<body>
<form name="frm" id="frm" method="post" enctype="multipart/form-data">
<input type="radio" name="send_type" id="send_type1" value="1"> 하나
<input type="radio" name="send_type" id="send_type2" value="2"> 둘
</form>
<a href="javascript:;" onclick="send_go();" class="boxb1">전송하기</a>
</body>
</html>
댓글을 작성하려면 로그인이 필요합니다.
체크를 해야지 focus를 주어서 무엇을 하겠다는 것인가요?
focus가 아니라 체크를 하는 것이 원하는 처리 같은데요?
$('input[name="send_type"]:eq(1)').prop('checked',true);
댓글을 작성하려면 로그인이 필요합니다.
라디오 버튼에는 포커스 액션이 별도로 없습니다..
만약 해당 라디오버튼이 화면 밖이라면 별도의 표시는 없어도 해당 위치로 스크롤이 되긴 합니다.
function send_go(){
$('#send_type2').focus();
}
전송하기
하나
둘
둘
채크해보세요.
댓글을 작성하려면 로그인이 필요합니다.
질문자입니다.
최대한 간략하게 정리했습니다.
코드가 동작안하는 이유가 뭘까요?
function send_go(){
$(':radio[name="send_type"]:eq(0)').focus();
}
하나
둘
전송하기
댓글을 작성하려면 로그인이 필요합니다.
다음 코드가 도움이 될지 모르겠습니다.
input[type="radio"]:focus {
outline: 0.1em dotted highlight;
outline-offset: initial;
}
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
$(':radio[name="send_type"]').eq(0).focus();
로 한번 해보세요.
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인