Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
404 views
in Technique[技术] by (71.8m points)

javascript - 如何使用jQuery删除“disabled”属性?(How to remove “disabled” attribute using jQuery?)

I have to disable inputs at first and then on click of a link to enable them.

(我必须首先禁用输入,然后单击链接以启用它们。)

This is what I have tried so far, but it doesn't work.

(这是我到目前为止所尝试的,但它不起作用。)

HTML:

(HTML:)

<input type="text" disabled="disabled" class="inputDisabled" value="">

jQuery:

(jQuery的:)

$("#edit").click(function(event){
   event.preventDefault();
   $('.inputDisabled').removeAttr("disabled")
});


This shows me true and then false but nothing changes for the inputs:

(这显示我是true然后是false但输入没有任何变化:)

$("#edit").click(function(event){
   alert('');
   event.preventDefault();
   alert($('.inputDisabled').attr('disabled'));
   $('.inputDisabled').removeAttr("disabled");
   alert($('.inputDisabled').attr('disabled'));
});
  ask by fatiDev translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.7k users

...