Home > Web Front-end > H5 Tutorial > How the HTML 5 input placeholder attribute can perfectly serve as ie_html5 tutorial skills

How the HTML 5 input placeholder attribute can perfectly serve as ie_html5 tutorial skills

WBOY
Release: 2016-05-16 15:47:48
Original
1857 people have browsed it

记得引用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();
});
});

页面调用

复制代码
代码如下:










样式

复制代码
代码如下:


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template