How to do following mask input problem?(如何做以下掩码输入问题?)
问题描述
我有一个脚本来屏蔽一个文本框,在这里它
i am having a script to mask a textbox,here it it
<script src="http://jquery-joshbush.googlecode.com/
files/jquery.maskedinput-1.2.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(function($) {
$('#j').mask('99:99');
});
</script>
我还有一个脚本可以在我单击按钮时动态添加文本框
i am also having a script to dynamically add text box while i click a button
<script type="text/javascript">
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for(var i=0; i<colCount; i++) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[0].cells[i].innerHTML;
//alert(newcell.childNodes);
switch(newcell.childNodes[0].type) {
case "text":
newcell.childNodes[0].value = "";
newcell.childNodes[0].id="j";
alert(newcell.childNodes[0].id);
break;
case "checkbox":
newcell.childNodes[0].checked = false;
break;
case "select-one":
newcell.childNodes[0].selectedIndex = 0;
break;
}
}
}
function deleteRow(tableID) {
try {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && true == chkbox.checked) {
if(rowCount <= 1) {
alert("Cannot delete all the rows.");
break;
}
table.deleteRow(i);
rowCount--;
i--;
}
}
}catch(e) {
alert(e);
}
}
</script>
而我的输入框是
<INPUT type="text" name="STime[]" id="j"/>
<INPUT type="text" name="ETime[]" id="j"/>
我现在面临的问题是,第一个文本框将具有蒙版结构,但是在我借助 j 脚本动态添加文本框后,我不会将文本框设为蒙版?为什么?我做错了什么?
the problem i am facing now is, the first text box will have a masked structure,but after i add a text box dynamically with help of j script, i will not get the text box as masked?why?? what i did wrong?
推荐答案
使用 livequery 插件一个>.然后给出你想要屏蔽类 maskme
的所有元素.现在你可以这样做了:
Use the livequery plug-in.
Then give all elements you want to mask the class maskme
. Now you can do:
$(".maskme").livequery(function(){
$(this).mask('99:99');
});
这将屏蔽即使在代码首次运行之后添加的输入.
This will mask inputs added even after the code is first run.
这篇关于如何做以下掩码输入问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何做以下掩码输入问题?


基础教程推荐
- 如何添加到目前为止的天数? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01