从code后面的jQuery电话 [英] Call jquery from code behind
本文介绍了从code后面的jQuery电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我有它执行一个按钮被点击的时候,我还需要背后基于一个项目是否附加了注释,从我的code执行此功能的jQuery函数。这里是jQuery的
Hi i have a jquery function which executes when a button is clicked, i also need to execute this function from my code behind based on whether an Item has a comment attached to it. Here is the jquery
//Comments Slide
$('.commentsnr').live("click", function () {
// up to parent li
$li = $(this).closest('li');
$li.find("#commentload").slideToggle(300);
});
我怎么后面把这个从我的code,非常感谢
How do i call this from my code behind, thanks alot
推荐答案
您可以做到这一点,但它只会在页面被交付或收到回发执行。
You can do this, but it will only be executed when the page is delivered or you receive a Postback.
请参阅http://msdn.microsoft.com/de-de/library/z9h4dk8y.aspx对于文档。
string jquery = "$('.commentsnr').live(\"click\", function () {$li = $(this).closest('li');$li.find(\"#commentload\").slideToggle(300);});"
ClientScript.RegisterStartupScript(typeof(Page), "a key",
"<script type=\"text/javascript\">"+ jquery +"</script>"
);
这篇关于从code后面的jQuery电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文