C# 如何从服务器端调用jquery函数
我有两个从服务器端代码动态创建的文本框(txtFrom&txtTo)。我想在这些文本框的mouseup事件上调用jquery函数。我怎么能这样做呢。下面给出了我的jquery函数C# 如何从服务器端调用jquery函数,c#,jquery,C#,Jquery,我有两个从服务器端代码动态创建的文本框(txtFrom&txtTo)。我想在这些文本框的mouseup事件上调用jquery函数。我怎么能这样做呢。下面给出了我的jquery函数 <script type="text/javascript"> $(document).ready(function() { $('#txtFrom').datepicker({ //appendText:'mm/dd/yyyy', showOn: 'both',
<script type="text/javascript">
$(document).ready(function() {
$('#txtFrom').datepicker({
//appendText:'mm/dd/yyyy',
showOn: 'both',
buttonText: '..',
dateFormat: 'dd/mm/yy',
//numberOfMonths:2,
changeMonth: true,
changeYear: true,
minDate: new Date(2017, 4, 1),
maxDate: new Date(2025, 3, 31)
});
});
我希望在这些文本框的onclick或onmouseup事件中调用jquery函数。您只需要使用jquery.on来连接动态控件的事件 请尝试下面的代码
<script type="text/javascript">
$(document).ready(function() {
$(document).on("click","input[id*='txtFrom']",function(){ //whatever code you want });
$(document).on("click","input[id*='txtTo']",function(){ //whatever code you want });
});
</script>
$(文档).ready(函数(){
$(document).on(“单击”,“输入[id*='txtFrom']”,function(){///您想要的任何代码});
$(document).on(“单击”,“输入[id*='txtTo']”,function(){///您想要的任何代码});
});
注意:如果有人要求显示您的代码,您需要更新
提问而不是添加答案。请把它拿走
那么这里的问题是什么?您共享的代码是什么?您在使用此代码时面临哪些问题?预期的行为是什么?您能分享动态添加文本框的代码吗?您的问题毫无意义为什么要从服务器端调用jquery函数?这是可能的,但您可能不需要这样做,所以请解释为什么要这样做。
<script type="text/javascript">
$(document).ready(function() {
$(document).on("click","input[id*='txtFrom']",function(){ //whatever code you want });
$(document).on("click","input[id*='txtTo']",function(){ //whatever code you want });
});
</script>