检查标签值更改 [英] Check label value change

查看:123
本文介绍了检查标签值更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<label id="error_msg"></label>

现在,我想提醒一个消息,请填写文本框,每当有价值变化的 error_msg

Now, I want to alert a message that please fill text-box, whenever there is change in value of error_msg

此外,我想检查标签是否为空。如果标签为空,那么提醒不应该出现。

Also, I want to check whether label is empty or not. If label is empty, then alert should not come.

我写了代码,但它不起作用

I wrote the code, but it's not working somehow

$("#error_msg").change(function () {
    alert('hi');
});

帮助家伙。

推荐答案

您需要监控标签的Dom更改。在 http://james.padolsey.com/javascript上查看易于使用的jQuery插件/ monitoring-dom-properties /

You need to monitor Dom changes for label. Check out the easy to use jQuery plugin at http://james.padolsey.com/javascript/monitoring-dom-properties/

如果您尝试验证,我强烈建议使用验证插件 http://bassistance.de/jquery-plugins/jquery-plugin-validation/

If you are trying to validate, i highly suggest using the validation plugin http://bassistance.de/jquery-plugins/jquery-plugin-validation/

这篇关于检查标签值更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆