您现在的位置是:网站首页> 编程资料编程资料

HTML 5 input placeholder 属性如何完美兼任ie详解移动端HTML5页面端去掉input输入框的白色背景和边框(兼容AndroidHTML5 input元素类型:email及url介绍html5 input属性使用示例HTML5输入框下拉菜单功能的示例代码html5实现输入框fixed定位在屏幕最底部兼容性HTML5中input输入框默认提示文字向左向右移动的示例代码

2021-09-01 1209人已围观

简介 这篇文章主要介绍了HTML 5 input placeholder 属性完美兼任ie的方法,需要的朋友可以参考下

记得引用jquery 类库

复制代码
代码如下:

$(document).ready(function () {
if ($.browser.msie)
$("input:text,input:password").each(function () {
var $placeholder = $(this).attr("placeholder");
var $width = $(this).css("width");
var $id = $(this).attr("id");
var $height = parseInt($(this).css("height")) + 6 + "px";
var $fontSize = $(this).css("font-size");
var $fontWeight = $(this).css("font-weight");
var $lineHeight = $height;
if ($(this).css("line-height") != "normal") {
$lineHeight = parseInt($(this).css("line-height")) + 6 + "px";
}
if ($placeholder != undefined) {
$(this).after("" + $placeholder + "");
}
$(this).bind("keyup", function () {
if ($(this).val() == "") {
$(this).parent().find(".ph_" + $id).css("display", "inline-block");
}
else {
$(this).parent().find(".ph_" + $id).css("display", "none");
}
});
});
$(".placeholder").live("click", function () {
$(this).prev().focus();
});
});

页面调用

复制代码
代码如下:










样式

复制代码
代码如下:


相关内容

-六神源码网