Created
February 17, 2012 11:23
-
-
Save alexzhan/1852788 to your computer and use it in GitHub Desktop.
add the compatibility to IE for showing the placeholder content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in HTML: | |
<textarea id="pubtextarea" placeholder="你在想什么?"></textarea> | |
in Javascript: | |
$(document).ready(function() { | |
var ie = document.all ? 1 : 0 | |
if(ie){ | |
$("#pubtextarea").val("你在想什么?"); | |
$("#pubtextarea").css("color","#A9A9A9"); | |
} | |
}); | |
$('#pubtextarea').focus(function() { | |
var ie = document.all ? 1 : 0 | |
if(ie) | |
if($("#pubtextarea").val()=="你在想什么?") | |
$("#pubtextarea").val(""); | |
$("#pubtextarea").css("height","60"); | |
$("#pubtextarea").css("color","#555"); | |
$(".submit-btn").show(); | |
}).blur(function() { | |
var ie = document.all ? 1 : 0 | |
if($("#pubtextarea").val() == ""){ | |
$('.submit-btn').hide(); | |
$('#pubtextarea').css('height','18'); | |
} | |
if(ie) | |
if($("#pubtextarea").val()==""){ | |
$("#pubtextarea").val("你在想什么?"); | |
$("#pubtextarea").css("color","#A9A9A9"); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment