简体   繁体   中英

jquery change not fire

I've a problem with jquery change! This is my .php page

 <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

$('#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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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