使用$ .noConflict时出现jQuery问题 [英] I have a jquery problem when using $.noConflict

查看:80
本文介绍了使用$ .noConflict时出现jQuery问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在我的项目中使用noConflict方法.但是我对此有疑问. 如果我不使用此方法,则项目运行正常. 但是,如果我使用此方法,则会出现错误.我该如何解决这个问题.

Hi I have to use noConflict method in my project. But I have a problem about this. İf I dont use this method, project is working correctly. But if I use this method, I have a error. How can I solve this problem.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title></title>
  <script type='text/javascript' src="javascripts/jquery.min.js"></script>
  <script type="text/javascript">
    $.noConflict(); // İf I dont use this method, project is working correctly.
                    // But if I use this method, I  have a error 
  </script>
  <script language="javascript" type="text/javascript">
    function goster() {
        alert($("#TextBox1").val());
    }
  </script>
</head>
<body>
  <form id="form1" runat="server">
    <asp:TextBox ID="TextBox1" onBlur="goster();" runat="server"></asp:TextBox>
  </form>
</body>
</html>

推荐答案

如果使用$.noConflict();,则应使用jQuery而不是$.

If you use $.noConflict(); then you should use jQuery instead of $.

<script language="javascript" type="text/javascript">
    function goster() {
        alert(jQuery("#TextBox1").val());
    }
  </script>

请参阅演示. http://jsfiddle.net/UnUgP/3/

这篇关于使用$ .noConflict时出现jQuery问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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