[英]wrap() method doesn't seem to work in jQuery
$('input.text-1').wrap('<span class="textfield-1"></span>');
.textfield-1 { border: 1px solid #d00; display: none; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input type="text" class="text text-1" />
Wrap()
似乎不起作用。 我在Firebug中看不到<span>
包裹輸入。 如果將它們包裝起來,則輸入將被display: none
隱藏display: none
,但不是。
我在這里做錯了什么?
為我工作正常。 頁面上是否存在javascript錯誤,阻止了代碼執行?
這是我的測試。 元素確實變得不可見,我可以看到它包裹在跨度中。
<html>
<head>
<style type="text/css">
.textfield-1 {
border: 1px solid #d00;
display: none;
}
</style>
<script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$(function(){
$('input.text-1').wrap('<span class="textfield-1"></span>');
});
</script>
</head>
<body>
<input type="text" class="text text-1" />
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.