debugging - What is wrong with this jQuery .blur? -
i have jquery:
var testtitleval = $('#testtitle').val(); $('#testtitle').blur( function(){ if(testtitleval.length == 0){ $('#testtitle').val('title'); } }); to work on html:
<input type="text" id="testtitle"> what want accomplish when focus leaves input , there no text in input makes value title. reason not doing that. ideas?
you code bit off in if statement:
do instead:
$('#testtitle').blur( function(){ if($(this).val().length == 0){ $(this).val('title'); } });
Comments
Post a Comment