javascript - 我们什么时候赋值调用jQuery事件?

标签 javascript jquery html css

我有两个文本字段:

 <input type="text" id="ex_1" class="update">

 <input type="text" id="ex_2" class="update">

我在赋值的时候想要:

 jQuery("#ex_1").val(12); 

jQuery 事件调用如下但不是在更改时而是在分配值时调用:

 jQuery(".update").change();



  jQuery(".update").live('keyup change', function()
 {
   alert(jQuery(this).val());
 }

关于调用jQuery事件赋值?

最佳答案

你可以这样使用

$(".update").keyup(function () {
        $(this).trigger("change");
    });

    $(".update").change(function () {
        alert("change");
    });

DEMO

关于javascript - 我们什么时候赋值调用jQuery事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22198041/

相关文章:

java - 在 Struts 2 中使用 getText() 获取属性

javascript - 如何使用highchart动态将柱形图更改为镜像图

jquery - 计算文本区域中的字符

php - 用于 HTML 标记转换的正则表达式

html - CSS 中的渐变颜色百分比

javascript - 如何使用 javascript Object.defineProperty

javascript - 获取工具提示的宽度并计算位置(Twitter Bootstrap)

javascript - JS : Calculate midpoints of lines recursively

javascript - 具有输入类型范围问题的 Sweet alert 2 模态

html - div 导致下一部分不可见