Javascript OnBlur 不工作
我有一个默认情况下禁用的文本框... onclick 可以工作并使其能够输入,但是当我单击单选按钮时.. 它不会再次禁用文本框
有任何线索吗?
<input type="radio" name="group1" value="website" OnBlur="javascript:document.getElementById('websiteurl').disabled = true;" OnClick="javascript:document.getElementById('websiteurl').disabled = false;">
<input name="websiteurl" type="text" id="websiteurl" value="http://" size="50" disabled="true" />
预先感谢
李
I have a textbox which is disabled by default... the onclick works and enables it to be typed in, but when i click the radio button away.. it doesn't disable the textbox again
Any clues ?
<input type="radio" name="group1" value="website" OnBlur="javascript:document.getElementById('websiteurl').disabled = true;" OnClick="javascript:document.getElementById('websiteurl').disabled = false;">
<input name="websiteurl" type="text" id="websiteurl" value="http://" size="50" disabled="true" />
Thanks in advance
Lee
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
没有“启用”属性。您必须将禁用设置为“禁用”才能禁用输入,或删除属性“禁用”才能启用它。
禁用=“true”是错误的语法,应该禁用=“disabled”
There is no attribute "enabled". You would have to set disabled to "disabled" to disable an input, or remove the attribute "disabled" to enable it.
disabled="true" is the wrong syntax, it should be disabled="disabled"
没有
启用
属性。您使用disabled
并将其设置为true
或false
。除此之外:
使用小写属性(否则它不是有效的 XHTML);无需在其前面放置
javascript:
。此外,最好从 JavaScript 代码附加事件而不是内联它们。特别是如果您使用像 jQuery 这样的库,这非常简单:(
当然,
#id
会比input[name=group1][value=website]
更好选择器)There is no attribute
enabled
. You usedisabled
and set it totrue
orfalse
.Besides that:
Use lowercase attributes (otherwise it's not valid XHTML); there's no need to put
javascript:
in front of it.Additionally, it is better to attach events from JavaScript code instead of inlining them. Especially if you use a library like jQuery it's extremely easy:
(of course a
#id
would be much better instead of theinput[name=group1][value=website]
selector)将启用更改为禁用,它将起作用。
没有启用的属性。
Change enabled to disabled and it will work.
There is no enabled property.
不完全确定上下文,但是在这种情况下,复选框是否更适合禁用或启用文本框?
Not totally sure on the context, but wouldn't a checkbox be more appropriate in this situation to disable or enable a textbox?
尝试使用
disabled=true
而不是enabled=false
Try
disabled=true
instead ofenabled=false