我有一个输入字段
如何删除默认的文本“请填写此场”
我需要删除默认的文本请填写此领域 我使用jQuery设置标题为空功能
$('#Form input[type=text]').each(function() {
$(this).attr('title', ' ');
});
它工作正常,除IE和Safari。
然后我试图NOVALIDATE但这只适用于如果输入字段的形式为内
这里是我的示例代码
<head runat="server">
<title></title>
<style>
.div2 .grp {
position: relative;
margin: 0 2%;
margin-bottom: 31px !important;
line-height: normal !important;
}
.div2 input {
font-size: 14px;
padding: 6px 10px 6px 0 !important;
display: block;
width: 100%;
border: none;
border-bottom: 1px solid #757575;
background: transparent!important;
}
.div2 label {
font-size: 14px;
font-weight: normal;
position: absolute;
pointer-events: none;
left: 0;
top: 10px;
transition: .2s ease all;
-moz-transition: .2s ease all;
-webkit-transition: .2s ease all;
color:Black;
}
.div1 {
width: 14%;
padding: 1%;
float: left;
}
label {
display: inline-block;
max-width: 100%;
font-weight: bold;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="div1" >
<div class='div2'>
<div class="grp" id="divFirstName">
<input type="text" runat="server" id="TB_TestForm" onclick="TestForm()" onblur="TestForm()" required/>
<label>My first name<span class="reqstar">*</span></label>
<span class="required"></span>
</div>
</div>
</form>
</body>
</html>
<script>
function TestForm() {
var html = document.getElementById("divFirstName").style.position;
if (html == "relative" || html=="") {
document.getElementById("divFirstName").style.position = "inherit";
}
else {
document.getElementById("divFirstName").style.position = "relative";
}
}
</script>
请帮
显示输入字段的HTML。我假设你正在使用'placeholder'属性? – RobIII
请向我们展示您的html标记,同时确保您将输入设置为空字符串'“”'而不是空格'“”'就像您正在做的那样 – Ted
'除IE和Safari之外,它工作正常。无论如何,你应该使用'$('#form input [type = text] [title]')。removeAttr('title');' –