Reputation: 103
I want to get rid of "TypeError: $(...).live is not a function"
error. The code is below, I have tried but could not managed to fix it.
$(".search-text input[data-default], .gdlr-comments-area input[data-default]").each(function() {
var t = $(this).attr("data-default");
$(this).val(t), $(this).live("blur", function() {
"" == $(this).val() && $(this).val(t)
}).live("focus", function() {
$(this).val() == t && $(this).val("")
})
Upvotes: 0
Views: 49
Reputation: 1439
Here are the new and old ways to do the same thing as equivalent statements:
$( selector ).live( events, data, handler ); // jQuery 1.3+
$( document ).delegate( selector, events, data, handler ); // jQuery 1.4.3+
$( document ).on( events, selector, data, handler );
and more examples:
$( "a.offsite" ).live( "click", function() {
alert( "Goodbye!" ); // jQuery 1.3+
});
$( document ).delegate( "a.offsite", "click", function() {
alert( "Goodbye!" ); // jQuery 1.4.3+
});
$( document ).on( "click", "a.offsite", function() {
alert( "Goodbye!" ); // jQuery 1.7+
});
Upvotes: 1