主页 > 知识库 > HTML 5 input placeholder 属性如何完美兼任ie

HTML 5 input placeholder 属性如何完美兼任ie

热门标签:百度地图标注为什么总是封号 咸阳稳定外呼系统软件 智能芯电话机器人 地图标注柱状图 怎么做百度地图标注 400开头的电话好申请不 临海地图标注app 四川移动电销外呼客户管理系统 小朱地图标注
记得引用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("<span class=\"placeholder ph_" + $id + "\" style=\"width:" + $width + ";line-height:" + $lineHeight + ";height:" + $height + ";font-weight:" + $fontWeight + ";margin-left:-" + $width + ";font-size:" + $fontSize + "\">" + $placeholder + "</span>");
}
$(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();
});
});

页面调用

复制代码
代码如下:

<input id="n1" type="text" placeholder="我是提示内容正常" />

<input id="n2" type="text" placeholder="我是提示内容宽高" style="width:100px;height:100px;" />

<input id="n3" type="text" placeholder="我是提示内容我有其他样式" / style="width:300px;height:40px;font-weight:bold;">

<input id="n4" type="text" placeholder="还可以尝试下其他的" />


样式

复制代码
代码如下:

<style type="text/css">
.placeholder {display:inline-block;color:gray;vertical-align:top;overflow:hidden;}
</style>

标签:公主岭 陕西 平顶山 黄石 平凉 黄石 山南 南平

巨人网络通讯声明:本文标题《HTML 5 input placeholder 属性如何完美兼任ie》,本文关键词  HTML,input,placeholder,属性,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《HTML 5 input placeholder 属性如何完美兼任ie》相关的同类信息!
  • 本页收集关于HTML 5 input placeholder 属性如何完美兼任ie的相关信息资讯供网民参考!
  • 企业400电话

    智能AI客服机器人
    15000

    在线订购

    合计11份范本:公司章程+合伙协议+出资协议+合作协议+股权转让协议+增资扩股协议+股权激励+股东会决议+董事会决议

    推荐文章