一个jquery函数没有从页面加载事件后面的代码调用! [英] a jquery function not being called from code behind on page load event !

查看:49
本文介绍了一个jquery函数没有从页面加载事件后面的代码调用!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 $( document )。ready( function  ButtonEnable() {
alert(' hello');
});



和背后的代码是

 ScriptManager.RegisterClientScriptBlock( this  this  .GetType(),  script  ButtonEnable();); 



这个jquery没有工作虽然jquery加载完美我检查但它不工作(上面的这个功能......)



但当我使用javascript时效果很好

代码是......

  function  UpdateRow(btnid){

alert(' 你好');
};



 ScriptManager.RegisterClientScriptBlock( this  .GetType(),  script,< span class =code-string>  UpdateRow( + btnadd +  ); true ); 



任何人都可以告诉为什么jquery不起作用但javascript工作。

解决方案

(< span class =code-sdkkeyword> document )。ready( function ButtonEnable(){
alert(' hello');
});



和背后的代码是

 ScriptManager.RegisterClientScriptBlock( this  this  .GetType(),  script  ButtonEnable();); 



这个jquery没有工作虽然jquery加载完美我检查但它不工作(上面的这个功能......)



但当我使用javascript时效果很好

代码是......

  function  UpdateRow(btnid){

alert(' 你好');
};



 ScriptManager.RegisterClientScriptBlock( this  .GetType(),  script,< span class =code-string>  UpdateRow( + btnadd +  ); true ); 



任何人都可以告诉为什么jquery不起作用但javascript工作。


好的,你可以这样做。它的功能





 < script     type   =  text / javascript >  
// 这是一个示例函数
函数functionName(name){
alert(name);
}

// 使用jquery在页面加载时调用上面定义的函数


(document).ready(functionName(' some text' ))



< / script>



ps请检查您是否已正确加载jquery,将此行放在此代码上方的正文中



< script src =http:/ /code.jquery.com/jquery-1.11.2.min.js\"></script> 


$(document).ready(function ButtonEnable() {
            alert('hello');
        });


and code behind is

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "ButtonEnable();", true);


this jquery did not worked though jquery loaded perfectly i checked but its not working (this function above...)

but when i use javascript its working well
code is...

function UpdateRow(btnid) {

            alert('hello');
        };


ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "UpdateRow("+btnadd+");", true);


can anyone please tell why jquery not worked but javascript worked.

解决方案

(document).ready(function ButtonEnable() { alert('hello'); });


and code behind is

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "ButtonEnable();", true);


this jquery did not worked though jquery loaded perfectly i checked but its not working (this function above...)

but when i use javascript its working well
code is...

function UpdateRow(btnid) {

            alert('hello');
        };


ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "UpdateRow("+btnadd+");", true);


can anyone please tell why jquery not worked but javascript worked.


Ok, you can do it like this. It functions


<script type="text/javascript">
// this is a sample function
function functionName(name){
                alert(name);
            }

//calling the above defined function on page load using jquery


(document).ready(functionName('some text'))


</script>

p.s. Please check if you have correctly loaded the jquery by putting this line in the body above this code

<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>


这篇关于一个jquery函数没有从页面加载事件后面的代码调用!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆