jquery > 所有浏览器兼容 placeholder

<input type="text" id="header_search_text" class="inputtext"  placeholder="输入人名"  onfocus="" />

<script language="javascript">
<!--
$(document).ready(function () {
	addPlaceHolder($('#header_search_text'));
});

function addPlaceHolder(obj){
	obj.val(obj.attr('placeholder'));
	obj.click(function () {
		var obj = $(this);
		if (obj.val() == obj.attr('placeholder')) {
			obj.val('');
		}
	});
	obj.blur(function () {
		var obj = $(this);
		if ($.trim(obj.val()) == '') {
			obj.val(obj.attr('placeholder'));
		}
	});
}
							
//-->
</script>	

 

你可能感兴趣的:(placeholder)