.attr(“禁用”,“禁用”)问题 [英] .attr("disabled", "disabled") issue

查看:151
本文介绍了.attr(“禁用”,“禁用”)问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



$ p $ $('。someElement')。click(函数(){
if(someCondition){
console.log($ target.prev('input'))//给出正确的对象
$ target.toggleClass('open' ).prev('input')。attr('disabled','disabled');
} else {
$ target.toggleClass('open')。prev('input')。removeAttr 'disabled'); //这是工程
}
})

removeAttr 工作正常,但是当我需要再次添加残疾人时,它什么都不做。我的console.log被触发(并给我回正确的输入字段),所以我敢肯定,我的if语句的作品。但是,当我用Firefox中的firebug检查DOM时,disabled属性不会出现。

有人可以帮我吗?

PS:请不要专注于函数或if语句本身,它只是正常工作,不适用于残疾人士...



edit :它的输入类型=隐藏是否有可能被禁用不能在隐藏的字段上工作?

谢谢大家的贡献!我发现这个问题:

它是一个FIREBUG BUG !!!


我的代码工程。我已经要求PHP开发人员将隐藏的输入类型更改为输入类型文本。
禁用的功能有效。但是,萤火虫控制台不会更新这个状态!



你可以在这里测试这个萤火虫错误 http://jsbin.com/uneti3/3# 。 Thx to aSeptik作为示例页面。

更新:2012年6月:FF11中的Firebug仍然存在此错误。


I have this function toggles the disabled attribute form a input field:

$('.someElement').click(function(){     
  if (someCondition) {
     console.log($target.prev('input')) // gives out the right object
     $target.toggleClass('open').prev('input').attr('disabled', 'disabled');
  }else{
     $target.toggleClass('open').prev('input').removeAttr('disabled'); //this works
  }
})

the removeAttr works fine but when i need to add the disabled again it does just nothing. My console.log is triggered (and giving me back the right input field) so I'm sure that my if statement works. But when I inspect the DOM with firebug in firefox, the disabled attribute does not appear.

can someone help me?

PS: please don't focus on the function or the if statement itself, works fine its just that attr that does not work for disabled...

edit: its an input type="hidden" is it possible that disabled does not work on hidden fields?

解决方案

Thank you all for your contribution! I found the problem:

ITS A FIREBUG BUG !!!

My code works. I have asked the PHP Dev to change the input types hidden in to input type text. The disabled feature works. But the firebug console does not update this status!

you can test out this firebug bug by your self here http://jsbin.com/uneti3/3#. Thx to aSeptik for the example page.

update: 2. June 2012: Firebug in FF11 still has this bug.

这篇关于.attr(“禁用”,“禁用”)问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆