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?