有些話從搜索過,我想將它們包裝用div
然後點擊一個環節,去掉外wrap
,但我的代碼不工作了wrap
和unwrap
。哪裏錯了?謝謝。jQuery的字經,並刪除包沒有奏效
<?php $_GET['search']='this is a text'; ?>
<script type="text/javascript" src="../jquery.js" ></script>
<script>
$(document).ready(function() {
var words = '<?php echo $_GET['search']; ?>';
$(words).wrap('<div id="words" />');
$('body').append(words);
$('#click').click(function(){
$(words).unwrap('<div id="words" />');
});
});
</script>
<body>
<a id="click">remove me</a>
</body>