禁用html中的输入
Disable input in html
我正在用Javascript和Jquery mobile创建8个益智盒子游戏。我用<input readonly></input>
完成了这些箱子,我把它们都放在了一张9x9的桌子上。问题是,当我点击一个框来移动它时,即使它是只读的,移动设备也会尝试在其中写入并显示键盘。这不是我想要的。。。我想禁用输入或使用与<input>
不同的东西。我尝试使用disable="disabled",但仍然无效。这是代码:
<form name="box">
</center>
<table align="center">
<tr>
<td ><input name="casella1" value="8" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
<td ><input name="casella2" value="5" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
<td ><input name="casella3" value="2" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
</tr>
<tr>
<td ><input name="casella4" value="6" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
<td ><input name="casella5" value="3" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
<td ><input name="casella6" value="4" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
</tr>
<tr>
<td ><input name="casella7" value="1" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
<td ><input name="casella8" value="7" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
<td ><input name="casella9" value="" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
</tr>
</table>
</form>
您应该使用disabled="disabled"
而不是disable="disable"
!
如果您使用HTML5,那么包含disabled
属性就足够了,因为它是一个布尔属性。
$("input").attr("disabled","true");
是jQuery解决方案,在标记中设置disabled
是html解决方案。
相关文章:
- Angularjs$编译输入html或元素
- 将输入 html 元素动态关联到颜色选取器
- 如何使用 JavaScript 显示 html 输入:.html(' < input type=“text” /
- 在输入 HTML 表单上从 Java 脚本传递参数
- 如何根据用户输入 HTML 更新多个 SPAN 元素
- 如何计算输入 HTML 元素的宽度,使其与其内容的大小相匹配
- 如何在输入 html 中编写一个 js var 值
- Javascript:如何获取所选复选框的所有值,推送到数组,然后放入输入HTML元素
- 如何使用Javascript自动输入html中行的序列号
- 特殊的点屏蔽输入 HTML-JavaScript
- 在select选项和input.text之间切换输入html
- 隐藏输入(html表单确认)-服务器端脚本?(php)
- 验证用户输入HTML子集
- 在KeyUp上输入HTML/JavaScript密码,用于浏览器自动填充
- 按钮内文本输入- HTML
- 在ie10,9中选择选项(html 5标签)在下一个输入(html 5标签)的位置
- 有麻烦输入html列表选项从xml文件
- 在非输入html标签上使用ng-keyup
- 在表数据中输入Html文本
- 中心文件输入- Html/Css