I’m beginner to jquery, how to call this script in an .aspx page?
var text = '';
$('p').bind('keypress', function(e) {
e.preventDefault();
$(this).text('');
$(this).empty();
text += String.fromCharCode(e.keyCode);
var text2 = text.substr(0, text.length - 1);
var lastChar = text.substr(text.length - 1);
$(this).text(text2);
$(this).append('<span class="char">' + lastChar + '</span>');
$(this).append('<span class="cursor"></span>');
});
appreciate any help, thanks
First of all, wrap your code into a function. Use one of the following to write a call to the function.
RegisterClientScriptBlock
RegisterStartupScript