我有一个错误<div>
当用户将焦点重新放回文本框时,我想清除文字。
问题是当我设置焦点时,功能不会触发?
$(".mod_EasyTabCalculator_device_contribution_text").focus(function () {
$("#mod_EasyTabCalculator_display_error_msg").text("");
});
HTML
<div id="mod_EasyTabCalculator_device_contribution">
<p id="mod_EasyTabCalculator_device_price_text">Enter your
<br />upfront contribution</p>
<div id="mod_EasyTabCalculator_device_text_box">
<input class="go" id="mod_EasyTabCalculator_device_dollar_sign">
<input type="text" value="" class="mod_EasyTabCalculator_device_contribution_text" name="down" id="mod_EasyTabCalculator_device_contribution_text" placeholder="Amount*" maxlength="6" size="6" runat="server" />
</div>
<input id="mod_EasyTabCalculator_device_contribution_button" type="button" class="btn" value="Calculate Payment" onclick="calculatePayment()" />
</div>
</form>
答案 0 :(得分:0)
如果mod_EasyTabCalculator_device_contribution_text
是您的输入ID,则需要使用#
$("#mod_EasyTabCalculator_device_contribution_text").focus(function () {
$("#mod_EasyTabCalculator_display_error_msg").text("");
});
答案 1 :(得分:0)
您需要在文档中添加jquery,如下所示:
$(document).ready(function(){
$(".mod_EasyTabCalculator_device_contribution_text").focus(function () {
alert("focus in!");
$("#mod_EasyTabCalculator_display_error_msg").text("");
});
});