[Is.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 () {

            // myForm 영역에 submit 버튼이 있는지 검사

            if ($('#myForm').children().is("input[type=submit]")) {

                alert("있다.");

            }

            else {

                alert("없다.");

            }

        });

    </script>

</head>

<body>

 

<div id="myForm">

    <input type="text" />

</div>

 

</body>

</html>

 



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




[실행결과]

--> 위의 [Is.htm]소스코드에서 <div>태그 내에서는 <input type="text" />로 입력하였지만, 위의 is("input[type=submit]")에서 "type=submit"는 [Is.htm]소스코드 내에 존재하지 않으므로 아래그림과 같이 메시지박스가 출력되었다.







Posted by holland14
: