新聞中心
js/jquery怎么移除已添加的屬性?
以下二種方法是可以為input添加disabled屬性的方法:
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)建站!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、小程序制作、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了天臺免費建站歡迎大家使用!
//兩種方法設(shè)置disabled屬性
$('#areaSelect').attr("disabled",true);
$('#areaSelect').attr("disabled","disabled");
以下三種方法是移除(去除)掉input的disabled屬性的方法:
//三種方法移除disabled屬性
$('#areaSelect').attr("disabled",false);
$('#areaSelect').removeAttr("disabled");
$('#areaSelect').attr("disabled","");
jquery中哪個方法可以刪除元素?
有兩個方法可以刪除元素:
remove 刪除被選元素(及其子元素)
empty 從被選元素中刪除子元素
jquery怎么移除屬性removeprop
jQuery removeProp()用來刪除由.prop()方法設(shè)置的屬性集
var $para = $("p");
$para.prop("luggageCode", 1234);
$para.append("The secret luggage code is: ", String($para.prop("luggageCode")), ". ");
$para.removeProp("luggageCode");
$para.append("Now the secret luggage code is: ", String($para.prop("luggageCode")), ". ");
如何刪除jQuery對象中元素?
1、可以這樣做:1234window._obj = '張三';//定義對象,這時候有了一個對象_objconsole.log,控制臺輸出對象:張三delete window._obj;//刪除對象nameconsole.log(window._obj);//控制臺輸出:Undefind,1$('#your_id').remove。
2、$(document).ready(function(){ $(".tab1_tag1_con a").click(function(){ var $abca=$(this).html(); var $parent = $(".tab1_tag2_con"); var $parentlen=$(".tab1_tag2_con").children("a").length; alert('a href="javascript:void(0)"'+$abca+'/a'); if ($parentlen9) { $parent.append('a href="javascript:void(0)"'+$abca+'/a'); } else { alert("不能添加超過10個"); } }); $(".input_bt7").click(function(){ var $city = $("#input_bt77").attr("value"); var $parent = $(".tab1_tag2_con"); $parent.append($city); }); $(".tab1_tag2_con a").click(function(){ $(this).remove(); }); }); 刪除tab1_tag2_con a里原有的a就可以,但是不能刪除后來添加的a。
3、remove方法移除被選元素,包括所有文本和子節(jié)點,該方法不會把匹配的元素從 jQuery 對象中刪除,因而可以在將來再使用這些匹配的元素。
4、但除了這個元素本身得以保留之外,remove不會保留元素的 jQuery 數(shù)據(jù),其他的比如綁定的事件、附加的數(shù)據(jù)等都會被移除。
網(wǎng)站名稱:jQuery刪除元素屬性,jq刪除元素的方法
網(wǎng)頁網(wǎng)址:http://www.dlmjj.cn/article/dssgphp.html