You probably can't get a div inside a p because they aren't allowed there, per the w3c spec:

"The P element represents a paragraph. It cannot contain block-level elements (including P itself)."

(and DIV is a block-level element)

http://www.w3.org/TR/html401/struct/text.html#h-9.3.1

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Sep 7, 2009, at 11:35 AM, TSAI wrote:


I have the following source code:
************************************************************************************
<head>
        <title>Untitled</title>
        <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
        <script type="text/javascript">
        <!--
                $(function () {
                        var $d = $('p > div');
                        $d.css('border', '1px solid gray');
                });
        //-->
        </script>
</head>

<body>

<p>
        <div>
                p - div
        </div>
</p>
</body>
************************************************************************************
I can't get the <div> inside <p>.
and I changed the source code, upset the <div> and <p>, and the
selector $('p > div') → $('div > p'):
************************************************************************************
<head>
        <title>Untitled</title>
        <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
        <script type="text/javascript">
        <!--
                $(function () {
                        var $d = $('div > p');
                        $d.css('border', '1px solid gray');
                });
        //-->
        </script>
</head>

<body>

<div>
        <p>
                div - p
        </p>
</div>
</body>
************************************************************************************
and i can get <p> inside <div>.
Who can tell me why?

Reply via email to