简体   繁体   English

jQuery更改不触发

[英]jquery change not fire

I've a problem with jquery change! 我有一个jQuery更改的问题! This is my .php page 这是我的.php页面

 <input id="numero_preventivi" style="display: none;" value="<?php echo $numeriPreventivi['preventivi']; ?>"/>
<input id="numero_preventivi_new" style="display: none;" value="0"/>

<script type="text/javascript">
$(function (){
    var num_pr = $("#numero_preventivi").val();
    var preventivi = new flipCounter('preventivi', {value: num_pr, inc:0, pace:600, auto:false});

    $("#numero_preventivi_new").change(function (){
        var num_pr_new = $("#numero_preventivi_new").val();
        preventivi.incrementTo(num_pr_new);
        });

});

And this is my .js function 这是我的.js函数

$('#numero_preventivi_new').val(text[0]).change();

When my function, in .js page, change value of my hidden div I would fire .change(), but I can't run the function into jquery code. 当我的函数在.js页面中更改隐藏的div的值时,我将触发.change(),但无法将函数运行到jquery代码中。 Where is the problem? 问题出在哪儿?

Changing the attribute doesn't change the value. 更改属性不会更改值。 Try this: 尝试这个:

$('#numero_preventivi_new').val(text[0]).change();

Working demo: http://jsbin.com/acojed 工作演示: http//jsbin.com/acojed

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM