Skip to content

Instantly share code, notes, and snippets.

@alexzhan
Created February 17, 2012 11:23
Show Gist options
  • Save alexzhan/1852788 to your computer and use it in GitHub Desktop.
Save alexzhan/1852788 to your computer and use it in GitHub Desktop.
add the compatibility to IE for showing the placeholder content
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