JavaScript Tutorial/jQuery/before — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 11:25, 26 мая 2010
Содержание
Add tag before
<source lang="javascript">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").before("Hello");
}); </script> </head> <body> <body> b
p
</body>
</html></source>
Add text node before
<source lang="javascript">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").before( document.createTextNode("Hello") ); }); </script> </head> <body> <body> b
p
</body>
</html></source>
before(content): Insert content before each of the matched elements.
<source lang="javascript">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").before( $("b") ); }); </script> </head> <body> <body> asdf
asdf:
</body>
</html></source>
Inserts a DOM element before all paragraphs.
<source lang="javascript">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").before( document.createTextNode("Hello") ); }); </script> </head> <body> <body> asdf
asdf:
</body>
</html></source>
Inserts a jQuery object (similar to an Array of DOM Elements) before all paragraphs.
<source lang="javascript">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").before( $("b") ); }); </script> </head> <body> <body> asdf
asdf:
</body>
</html></source>
Inserts some HTML before all paragraphs.
<source lang="javascript">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").before("Hello"); }); </script> </head> <body> <body> asdf
asdf:
</body>
</html></source>