占位符在IE10中不起作用 [英] Placeholder not working in IE10
问题描述
html:
< div class =div-input>
< input type =textid =loginnamename =usernamevalue =maxlength =25
class =form-inputplaceholder =用户名
/>
< / div>
< div class =div-input>
< input type =passwordid =loginpasswordname =passwordmaxlength =25
class =form-inputplaceholder =Password
/
< / div>
< div>
< input type =submitname =loginvalue =LOGINclass =form-button
onclick =return check_login(& quot; /&
/>
< span id =logInfo>< / span>< span style =display:none; id =overlay>< / span>
< span style =display:none; id =popup>
< img src =/ public / images / loading.gif/>
< / span>
< / div>我的问题是占位符在所有浏览器中正常工作,对于IE8和IE9我使用Javascript解决它,但在IE10的占位符是工作,但不是以正确的方式。
-
,如果占位符
是占位符,则在IE10中只能获得 Placeholde
作为占位符在输入框中单击,并在页面外显示正确的占位符占位符
。
-
在输入字段中输入任何字词我在输入字段的拐角处得到一个仅在IE10中发生的十字符号(关闭符号)。
解决方案我不知道placeHolder属性的输入支持在ie10,但如果u想要一个占位符,即u可以这样做通过jquery像这样下面的..
if(navigator.appVersion.match(/ MSIE [\d。] + /)){
var placeholderText ='Some Placeholder Text';
$('#loginname')。val(placeholderText);
$('#loginname')。blur(function(){
$(this).val()==''?$(this).val(placeholderText):false; $ b $ 。
$('#loginname')。focus(function(){
$(this).val()== placeholderText?$(this).val(''):false;
});
}
u对密码也可以这样做。
有人用这样的代码...我相信应该工作...
$('#loginname')。attr('placeholder','username');
$('#password')。attr('placeholder','password');
html:
<div class="div-input">
<input type="text" id="loginname" name="username" value="" maxlength="25"
class="form-input" placeholder="Username"
/>
</div>
<div class="div-input">
<input type="password" id="loginpassword" name="password" maxlength="25"
class="form-input" placeholder="Password"
/>
</div>
<div>
<input type="submit" name="login" value="LOGIN" class="form-button"
onclick="return check_login("/")"
/>
<span id="logInfo"></span><span style="display: none;" id="overlay"></span>
<span style="display: none;" id="popup">
<img src="/public/images/loading.gif" />
</span>
</div>
My problem is that the placeholder is working fine in all browsers, for IE8 and IE9 I used Javascript to solve it, but in IE10 the placeholder is working, but not in a correct manner.
What happens is that on page load, if Placeholder
is the placeholder, I get only Placeholde
as placeholder in IE10 (last letter disappears), but if I click in the input box and outside the page it shows the correct placeholder as Placeholder
.
If I type any word in the input field I am getting a cross symbol (close symbol) at the corner in the input field which is happening only in IE10.
解决方案 i am not sure about placeHolder attribute for input support in ie10,but if u want a placeholder in ie u can do this throug jquery like this below..
if(navigator.appVersion.match(/MSIE [\d.]+/)){
var placeholderText = 'Some Placeholder Text';
$('#loginname').val(placeholderText);
$('#loginname').blur(function(){
$(this).val() == '' ? $(this).val(placeholderText) : false;
});
$('#loginname').focus(function(){
$(this).val() == placeholderText ? $(this).val('') : false;
});
}
u can do same for password too..
Have U tried somewhat like this using code...i believe should work...
$('#loginname').attr('placeholder', 'username');
$('#password').attr('placeholder', 'password');
这篇关于占位符在IE10中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!