从文本框中删除文本

Moh*_*sir 1 javascript jquery jquery-ui

我在一个由几个字段组成的注册页面上工作,我只想知道如何从密码确认文本框中删除/隐藏文本。当密码和重新输入密码不匹配时。

这是我的代码

$('#txtConfirmPassword').blur(function() {
  if ($('#txtConfirmPassword').val() != $('#txtPassword').val()) {
    $('#spPasswordConfirmation').html('Password and Retype Password does not match.');
  } else {
    $('#spPasswordConfirmation').html('')
  }
});
Run Code Online (Sandbox Code Playgroud)

Lul*_*Ash 5

$('#spPasswordConfirmation').val('');
Run Code Online (Sandbox Code Playgroud)

代替

$('#spPasswordConfirmation').html('');
Run Code Online (Sandbox Code Playgroud)