未能获取服务器控件的ID [英] failed to get server control id

查看:147
本文介绍了未能获取服务器控件的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的.ascx

我想用我的jQuery来执行某些操作,下面的code是我如何调用服务器控件的ID。

  $(输入)。的mouseenter(函数(){
//一些功能
}<输入类型=文本ID =天伦之乐VALUE =家庭1 />
<输入类型=文本ID =family2VALUE =家庭2 =服务器/>

我的问题,现在是我的天伦之乐能够调用jQuery函数,但我的家人没有。

难道是因为我使用的.ascx 这样我就可以在服务器控件ID不能传递给我的jQuery?

是,任何想法解决?


解决方案

  $(文件)。就绪(函数(){
        $('。ctl00_m_g_3b0d8e69_1961_4bea_886d_413493ff7f9c_ctl00_checkclass)。悬停(函数(事件){
            警报('达达');
            变种C =警报($(本).attr(ID));
            警报(C);
        });
    });
<输入类型=文本ID =天伦之乐VALUE =天伦之乐级=checkclass/>
<输入类型=文本ID =family2VALUE =family2级=checkclass/>
<输入类型=文本ID =family3VALUE =family3级=checkclass/>

I using .ascx

I am trying to use my jQuery to perform some action, the below code is how I call server control id.

$("input").mouseenter(function() {
//some function
}

<input type="text" id="family1" value="family"1/> 
<input type="text" id="family2" value="family"2 runat="server"/> 

My problem right now is my family1 able to call jQuery function but my family doesn't.
Is it because I am using .ascx so I cannot pass the server control id to my jQuery?
Is that any idea to solve?

解决方案

 $(document).ready(function () {
        $('.ctl00_m_g_3b0d8e69_1961_4bea_886d_413493ff7f9c_ctl00_checkclass').hover(function (event) {
            alert('dada');
            var c = alert($(this).attr("id"));
            alert(c);
        });
    });


<input type="text" id="family1" value="family1" class="checkclass"/> 
<input type="text" id="family2" value="family2" class="checkclass" /> 
<input type="text" id="family3" value="family3" class="checkclass" />

这篇关于未能获取服务器控件的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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