[ShowBigImg.htm]



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>마우스 오버시 큰 이미지 보여주기</title>

    <script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function() {

            // 아래 코드는 모든 이미지 파일의 이미지명을 얻어,

            // bigs/ 폴더에 있는 동일한 이미지를 div에 보여준다.

            $('#product img').mouseover(function () {

                $("#showImage").show(); // 이미지 보여줄 레이어 보이기

                    var imgSrc = ""; // 이미지 소스 저장 변수

                    imgSrc = $(this).attr("src"); // attr() src get하기

                    imgSrc = imgSrc.substr(imgSrc.lastIndexOf("/") + 1); // 순수 파일명만 얻기

                    imgSrc = "<img src='../ProductImages/bigs/" + imgSrc + "' />"; // 큰이미지 설정

                    $("#showImage").html(imgSrc); // 레이어에 HTML 추가

            });

            // 마우스 오버시 레이어 숨기기

            $('#product img').mouseout(function() {

                $("#showImage").hide(); // 레이어 숨기기

            });

        });

    </script>

</head>

<body>

<div id="product">

    <img src="../ProductImages/Book-01.jpg" />   

    <img src="../ProductImages/Hardware-01.jpg" />   

    <img src="../ProductImages/Online-01.jpg" />   

    <div id="showImage"

        style="border:1px solid red;width:400px;height:400px;">

    </div>

</div>

</body>

</html>

 



-------------------------------------------------------------------------------------




[실행결과]

--> 아래그림에서, 위에 있는 작은 3개의 이미지중 하나의 이미지에 마우스오버(mouseover)하면 그 아래에 해당이미지가 큰이미지로 출력된다.











Posted by holland14
:



[Attr.htm]

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>DOM요소의 attribute 읽어오기</title>

    <script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function() {

            //[1] get

            alert($('a').attr('href')); // get

 

            //[2] set : img에 마우스 오버시 이미지 변경

            $('img:first').mouseover(function() {

                $(this).attr("src",

                    "http://www.dotnetkorea.com/Website/Portals/0/dotnetkorealogo.gif");

            });

 

            //[3] 마우스오버/아웃시 다른 이미지 표시

            $('#copy').mouseover(function () {

                $(this).attr('src', "../images/icon_copy_over.gif");

            });

            $('#copy').mouseout(function () {

                $(this).attr('src', "../images/icon_copy.gif");

            });

        });

    </script>

</head>

<body>

 

<a href="http://www.dotnetkorea.com/">닷넷코리아</a>

 

<img src="images/logo.jpg" alt="닷넷코리아로고" />

 

<img src="../images/icon_copy.gif" id="copy" />

 

</body>

</html>




-------------------------------------------------------------------------------------




[실행결과]

--> 첫 화면.





--> 위의 그림에서 메시지박스의 '확인'버튼을 누른 후, 위의 그림의 "닷넷코리아로고"텍스트에 '마우스오버(mouseover)'시에 아래그림에서 해당 이미지가 출력된 화면.




--> 바로 위의 그림에서 맨 오른쪽에 있는 작은이미지에 '마우스오버(mouseover)'했을때 화면.




--> 바로 위의 그림에서 맨 오른쪽에 있는 작은이미지에서 '마우스아웃(mouseout)'했을때 화면.



Posted by holland14
:



[Selected.htm]



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>드롭다운리스트 선택한 값 가져오기</title>

    <script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function() {

            // 콤보박스가 변경될 때

            $('#lstFavorites').change(function () {

                // 드롭다운리스트에서 선택된 값을 텍스트박스에 출력

                var selectedText = // $("#lstFavorites option:selected").text();

                    // $("option:selected").text();

                    $(":selected").text();

                $('#txtFavorite').val(selectedText);

            });

        });

    </script>

</head>

<body>

 

<select id="lstFavorites">

    <option>C#</option>

    <option>ASP.NET</option>

    <option>Silverlight</option>

</select>

<hr />

<input type="text" id="txtFavorite" />

 

</body>

</html>

 



-------------------------------------------------------------------------------------




[실행결과]

--> 아래그림에서 "드롭다운리스트"에서 선택한대로 드롭다운리스트 아래에 있는 "텍스트박스"에 드롭다운리스트와 같은 값이 출력된다.










Posted by holland14
:



[PasswordConfirm.htm]



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>암호확인 기능 구현하기</title>

    <script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function() {

            //[1] lblError 레이어 클리어

            $('#txtPassword').keyup(function() {

                //$('#lblError').remove(); // 제거

                $('#lblError').text(''); // 클리어

            });

 

            //[2] 암호 확인 기능 구현

            $('#txtPasswordConfirm').keyup(function() {

                if ($('#txtPassword').val() != $('#txtPasswordConfirm').val()) {

                    $('#lblError').text(''); // 클리어

                    $('#lblError').html("<b>암호가 틀립니다.</b>"); // 레이어에 HTML 출력

                }

                else {

                    $('#lblError').text(''); // 클리어

                    $('#lblError').text("<b>암호가 맞습니다.</b>"); // 레이어에 텍스트 출력

                }

            });

        });

    </script>

</head>

<body>

    <table style="border: 1px solid skyblue;">

        <tr>

            <td>암호:</td>

            <td><input type="password" id="txtPassword" size="20" /></td>

        </tr>

        <tr>

            <td>암호확인:</td>

            <td><input type="password" id="txtPasswordConfirm" size="20" /></td>

        </tr>

    </table>

    <div id="lblError">암호를 입력하시오.</div>

</body>

</html>

 



-------------------------------------------------------------------------------------




[실행결과]


--> 첫 화면.








--> '암호'텍스트박스와 '암호확인'텍스트박스의 비밀번호가 다를 때의 화면. 




--> '암호'텍스트박스와 '암호확인'텍스트박스의 비밀번호가 같을 때의 화면.(아래 그림에서 텍스트박스 아래에 있는 레이블에 태그가 적용되지 않은 것을 볼 수 있다.)








Posted by holland14
:


[Text.htm]



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>텍스트박스의 값 복사</title>

    <style type="text/css">

        .silver { background-color:Silver; }

    </style>

    <script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function() {

            // 모든 텍스트박스의 배경을 Silver로 설정

            $(':text').addClass("silver");

 

            // 첫 번쩨 텍스트박스의 값을 두번째 텍스트박스로 복사

            $('#btnCopy').click(function() {

                $('#txtID').val($('#txtUserID:text').val());

            });

        });       

    </script>

</head>

<body>

<div>

    아이디 : <input type="text" id="txtUserID" />

    <hr />

    <input type="button" id="btnCopy" value="복사" />

    <hr />

    아이디 : <input type="text" id="txtID" />

</div>

</body>

</html> 





-------------------------------------------------------------------------------------




[실행결과]

--> 첫 화면.





--> 위의 그림에서 위에 있는 텍스트박스에 텍스트를 입력하고 바로 아래에 있는 '복사'버튼을 클릭하면 '복사'버튼 아래에 있는 텍스트박스에 위의 텍스트박스에 입력된 텍스트가 복사되어 출력된다. 



Posted by holland14
:


[Input.htm]



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>모든 폼 요소 읽어오기</title>

    <script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function() {

            var result = "";

            // 폼 요소가 있는 만큼 반복하자.

            //alert($(':input').size());

            $(':input').each(function(index) {

                result += "태그명 : " + $(this).get(0).tagName // this.tagName

                    + ", type 속성명 : " + $(this).attr('type') + '\n';

            });

            alert(result);

        });       

    </script>

</head>

<body>

    <input type="button" value="Input Button"/><br />

    <input type="text"/><br />

    <input type="password"/><br />

    <input type="checkbox"/><br />

    <input type="file"/><br />

    <input type="hidden"/><br />

    <input type="image"/><br />

    <input type="radio"/><br />

    <input type="reset"/><br />

    <input type="submit"/><br />

    <select><option>드롭다운리스트</option></select><br />

    <textarea>멀티라인텍스트박스</textarea><br />

    <button>버튼</button><br />

</body>

</html>

 




-------------------------------------------------------------------------------------




[실행결과]








Posted by holland14
:


[jQueryIndexer.htm]



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>HTML 요소 가져오기</title>

    <script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function () {

            // h3 요소 모두 가져오기

            var headers = $('h3');

           

            // 반복문을 써서 반복 : for문보다는 jQuery each문이 사용하기 편리

            for (var i = 0; i < headers.length; i++) {

                alert($(headers[i]).html());

            }

           

            // 위 코드를 each문으로 변경?

            $('h3').each(function (index) {

                alert($(this).html());

            });

        });           

    </script>

</head>

<body>

<h3>제목1</h3>

<h3>제목2</h3>

</body>

</html>

 



-------------------------------------------------------------------------------------



[실행결과]

--> "for"문을 사용하여 '메시지박스' 2번 출력..,









--> "each"문을 사용하여 '메시지박스' 2번 출력..,









--> 바로 위의 그림에서 메시지박스의 '확인'버튼을 누른 후의 화면.








Posted by holland14
:


[Each.htm]



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>요소만큼 반복해서 속성 설정 및 가져오기</title>

    <script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function() {

            //[1] each 메서드 설명

            //$('p').each(function (index) { alert(index); });

            //[2] for문처럼 반복한다. index 0부터 자동 증가됨

            $('p').each(function (index) {

                $(this).attr({      // attr({어트리뷰트:});

                    'id': "para-" + index

                });

            });

            //[3] 0번째 요소의 텍스트 읽어오기

            $('#btn').click(function () {

                alert($('#para-0').text()); // 태그내의 텍스트 읽어오기(text() : 태그안의 값 : C#)

            });

        });   

    </script>

</head>

<body>

    <p>C#</p>

    <p>ASP.NET</p>

    <p>Silverlight</p>

    <input type="button" id="btn" value="동적으로 생성된 id로 개체 접근" />

</body>

</html>

 

 

 


-------------------------------------------------------------------------------------




[실행결과]

--> 첫 화면.




--> 위의 그림에서 '동적으로 생성된 id로 개체 접근'버튼을 누른 후의 화면.







Posted by holland14
:


 
  1. 콜백 : 데이터가 아닌 함수를 매개변수로 전달
  2. (Map) : 한번에 여러 개의 매개변수를 전달
    • Map Array 또는 Collection 동일한 의미로 사용






[CallBack.htm]



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>콜백 : 매개변수로 함수를 전달</title>

    <style type="text/css">

    </style>

    <script src="js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function () {

            $('p:eq(1)')                                                //[1] 두번째 p 태그 영역

                .css('backgroundColor', 'Yellow')                       //[2] 두번째 영역의 배경색 지정

                .click(function () {

                    var $thisPara = $(this);                            //[3] 현재 영역을 변수에 설정

                    $thisPara.next()

                        .slideDown('slow', function () {                //[4] 두번째의 다음 요소를 슬라이드 다운

                            $thisPara.slideUp('slow');                  //[5] 현재자신(두번째)를 슬라이드 업

                        });

                });

        });

    </script>

</head>

<body>

    <p>첫번째</p>

    <p>두번째</p>

    <p style="display:none;">세번째</p>

    <p>네번째</p>

 

</body>

</html>

 





-------------------------------------------------------------------------------------




[실행결과]


--> 첫 화면. 아래그림에서 노란색 배경의 레이어로 칠해진 '두번째'텍스트를 클릭하면...




--> '두번째'레이어 아래에 '세번째'텍스트가 "슬라이드 다운(slideDown)"되면서 나타나면서 연이어서 바로 '두번째'텍스트가 "슬라이드업(slideUp)"되면서, '두번째'텍스트가 사라지면서 '두번째'텍스트 자리로 '세번째'텍스트가 올라간다.




Posted by holland14
:


[Browser.htm]



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>브라우저 버전</title>

    <style type="text/css">

    </style>

    <script src="js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function() {

            // IE 8.0이지만, 6.0으로 나타남

            alert('현재 웹 브라우저 버전은 : ' + jQuery.browser.version + '입니다.');

        });

    </script>

</head>

<body>

 

</body>

</html>

 




-------------------------------------------------------------------------------------




[실행결과]






Posted by holland14
: