not set

jQuery input box 선택시에 색상 넣기 본문

javascript/jQuery

jQuery input box 선택시에 색상 넣기

다크곰 2012. 1. 17. 17:49

http://api.jquery.com/focus-selector/ 

<!DOCTYPE html>
<html>
<head>
 
<style>
.focused {
    background
: #abcdef;
}
</style>
 
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
 
<div id="content">
   
<input tabIndex="1">
   
<input tabIndex="2">
   
<select tabIndex="3">
       
<option>select menu</option>
   
</select>
   
<div tabIndex="4">
        a div
   
</div>
</div>

<script>
$
( "#content" ).delegate( "*", "focus blur", function( event ) {
   
var elem = $( this );
    setTimeout
(function() {
       elem
.toggleClass( "focused", elem.is( ":focus" ) );
   
}, 0);
});
</script>

</body>
</html>



본문 출처 : 모던 웹을 위한 Javascript 입문 및 jQuery입문

'javascript > jQuery' 카테고리의 다른 글

jQuery 필터 선택자  (0) 2012.01.17
jQuery로 select box 및 check box의 값 가져오는 방법  (0) 2012.01.17
jQuery 속성 선택자  (0) 2012.01.17
jQuery 자식선택자, 후손 선택자  (0) 2012.01.17
jQuery 클래스 선택자  (0) 2012.01.17