简体   繁体   English

jQuery中不触发Change()函数

[英]Change() function not firing in jQuery

<script type="text/javascript" src="/Style Library/functions/jquery-1.11.3.min.js"></script>
<script type="text/javascript">

        $(document).ready(function(){
        $('#ctl00_m_g_3b1a3698_a0fa_4283_bf23_e830e012a848_ff21_ctl00_ctl00_TextField').val("1501");
        });

        $('#ctl00_m_g_3b1a3698_a0fa_4283_bf23_e830e012a848_ff161_ctl00_Lookup').change(function() {
        var str = $('#ctl00_m_g_3b1a3698_a0fa_4283_bf23_e830e012a848_ff161_ctl00_Lookup: selected').text();
        $('#ctl00_m_g_3b1a3698_a0fa_4283_bf23_e830e012a848_ff21_ctl00_ctl00_TextField').val(str);
        })
        .change();
</script>

The above code is working partially. 上面的代码部分起作用。 ready function works but the change function does not trigger. 就绪功能有效,但更改功能不会触发。 Any guidance please. 请任何指导。 The above code I am using in SharePoint NewForm.aspx page. 我在SharePoint NewForm.aspx页中使用的上述代码。

I changed my code as per given in below reference link and now my code is working as expected. 我按照下面的参考链接中的说明更改了代码,现在我的代码可以正常工作了。 The change function is firing now and on change the value is set in textbox: 更改功能现在会触发,更改后会在文本框中设置值:

Jquery select change not firing jQuery选择更改不触发

$(document.body).on('change','#ctl00_m_g_3b1a3698_a0fa_4283_bf23_e830e012a848_ff161_ctl00_Lookup',function(){

var str = $('#ctl00_m_g_3b1a3698_a0fa_4283_bf23_e830e012a848_ff161_ctl00_Lookup :selected').text();

$("#ctl00_m_g_3b1a3698_a0fa_4283_bf23_e830e012a848_ff21_ctl00_ctl00_TextField").val(str);    
});

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

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