日期:2014-05-16 浏览次数:20334 次
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://libs.baidu.com/jquery/1.8.3/jquery.js"></script>
<title>无标题文档</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
为什么点击两次“显示”按钮,代码才会正常运行,请在IE中调试。<br />
<input id="btn" type="button" value="显示" />
<div id="xxx" style="display: none; " >
<form>
<input type="password" placeholder="各位好1" />
</form>
</div>
</body>
<script type="text/javascript">
$("#btn").click(function(){
$("#xxx").show(0,jQuery.placeholder.shim());
});
(function($) {
// @todo Document this.
$.extend($,{ placeholder: {
browser_supported: function() {
if($.browser.msie || $.browser.opera)
{
return false;
}
return this._supported !== undefined ?
this._supported :
( this._supported = !!('placeholder' in $('<input type="text">')[0]) );
},
shim: function(opts) {
var config = {
color: '#f00',
cls: 'placeholder',
selector: 'input[placeholder], textarea[placeholder]'
};
$.extend(config,opts);
return !this.browser_supported() && $(config.selector)._placeholder_shim(config);
}
}});
$.extend($.fn,{
_placeholder_shim: function(config) {
function calcPositionCss(target)
{
var op = $(target).offsetParent().offset();
var ot = $(target).offset();
return {
top: ot.top - op.top,
left: ot.left - op.left,
width: $(target).width()
&n