新聞中心
js/jquery怎么移除已添加的屬性?
以下二種方法是可以為input添加disabled屬性的方法:

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)建站!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、小程序制作、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了天臺(tái)免費(fèi)建站歡迎大家使用!
//兩種方法設(shè)置disabled屬性
$('#areaSelect').attr("disabled",true);
$('#areaSelect').attr("disabled","disabled");
以下三種方法是移除(去除)掉input的disabled屬性的方法:
//三種方法移除disabled屬性
$('#areaSelect').attr("disabled",false);
$('#areaSelect').removeAttr("disabled");
$('#areaSelect').attr("disabled","");
jquery中哪個(gè)方法可以刪除元素?
有兩個(gè)方法可以刪除元素:
remove 刪除被選元素(及其子元素)
empty 從被選元素中刪除子元素
jquery怎么移除屬性removeprop
jQuery removeProp()用來(lái)刪除由.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對(duì)象中元素?
1、可以這樣做:1234window._obj = '張三';//定義對(duì)象,這時(shí)候有了一個(gè)對(duì)象_objconsole.log,控制臺(tái)輸出對(duì)象:張三delete window._obj;//刪除對(duì)象nameconsole.log(window._obj);//控制臺(tái)輸出: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("不能添加超過(guò)10個(gè)"); } }); $(".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就可以,但是不能刪除后來(lái)添加的a。
3、remove方法移除被選元素,包括所有文本和子節(jié)點(diǎn),該方法不會(huì)把匹配的元素從 jQuery 對(duì)象中刪除,因而可以在將來(lái)再使用這些匹配的元素。
4、但除了這個(gè)元素本身得以保留之外,remove不會(huì)保留元素的 jQuery 數(shù)據(jù),其他的比如綁定的事件、附加的數(shù)據(jù)等都會(huì)被移除。
網(wǎng)站名稱:jQuery刪除元素屬性,jq刪除元素的方法
路徑分享:http://www.dlmjj.cn/article/dssgphp.html


咨詢
建站咨詢
