JavaScript Tutorial/jQuery/replaceWith — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 11:25, 26 мая 2010
Replace text with
<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").replaceWith("
" + $(this).text() + "
");
}); </script> <style> div { border:2px green solid;} </style> </head> <body> <body>
Hello
</body>
</html></source>
Replace with another tag
<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").replaceWith("Paragraph. ");
}); </script> <style> div { border:2px green solid;} </style> </head> <body> <body>
Hello
</body>
</html></source>
replaceWith(content): Replaces all matched elements with the specified HTML or DOM 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(){ $("button").click(function () {$(this).replaceWith("
" + $(this).text() + "
");
}); }); </script>
</head> <body> <body> <button>First</button> </body>
</html></source>