function $(id){

  return document.getElementById(id);

  }

document.getElementById(id) 是获得id这个元素的。

相当于定义了一个方法,这样用  $("id0")就得到id为id0的控件了。

而这种定义的方法仅仅是在没有Jquery的工程中运用的,当你用啦$的话,再用Jquery的话,那么你所有关于Jquery的代码就都不能用啦,所以这里我们

不要被他的$唬住了,这只是一个变量名,随便取的,你用x也行,这样用的时候就是x("id0")。

 将以上代码改成以下代码,即将$改成x即可

function x(id){

  return document.getElementById(id);

  }

$是jquery里面的运算符

function $(id){ return document.getElementById(id); }导致所有的js不能用解决办法。。。。的更多相关文章

  1. function $(id) { return typeof id === "string" ? document.getElementById(id) : id; }

    function $(id) {   return typeof id === "string" ? document.getElementById(id) : id; } 这句代 ...

  2. jquery中的$("#id")与document.getElementById("id")的区别

    以前一直认为jquery中的$("#id")和document.getElementByIdx_x("id")得到的效果是一样的,今天做特效的时候才发现并不是这 ...

  3. jquery 中的 $("#id") 与 document.getElementById("id") 的区别

    以前没注意过,认为jquery 中的 $("#air") 与 document.getElementById("air") 是一回事,指的是同一个东西.在今天写 ...

  4. 封装document.getElementById(id)

      CreateTime--2016年12月18日11:42:45Author:Marydon封装document.getElementById(Id)方法 <script type=" ...

  5. document.getElementById("id").value与$("#id").val()之间的区别

    本文链接:https://blog.csdn.net/mottohlm/article/details/78364196....今天在项目中遇到这么一个JS报错:原因是代码中有这么一段:对,就是var ...

  6. Id.value与document.getElementById("Id").value的区别

    如果标签Id在Form表单里面的话,直接Id.value就不能用了,而是要用Form.Id.value来取值或设置值 所以最好用document.getElementById("Id&quo ...

  7. 获得输入框的文本document.getElementById('id').value;

    <input id="demo" type="text" value="" > x=document.getElementByI ...

  8. document.getElementById(“id”)与$("#id")的区别

    document.getElementById("id")可以直接获取当前对象, jQuery利用$("#id")获取的是一个[object Object],需 ...

  9. Response.Write()方法响应导致页面字体变大的解决办法

    关于ASP.NET中用Response.Write()方法响应导致页面字体变大的解决办法     最近研究了ASP.NET,发现一个问题,比方说在页面里面有个Button,要点击以后要打开新窗口,而且 ...

随机推荐

  1. How to Iterate Over a Map in Java?(如何遍历Map)

    1.Iterate through the "entrySet" like so: public static void printMap(Map mp) { Iterator i ...

  2. cannot create windows service for mysql

    这安装完mysql启动的时候总是弹出不能启动错误,解决办法: 先卸载掉MySQL干净:把关于MySQL所有目录及文件都删除掉,还有把注册表删除干净.在注册表找到以下项目并删除:HKEY_LOCAL_M ...

  3. JS学习之动态加载script和style样式

    前提:我们可以把一个网页里面的内容理解为一个XML或者说网页本身也就是一个XML文档,XML文档都有很特殊的象征:"标签"也叫"节点".我们都知道一个基本的网页 ...

  4. Gym 100917C Constant Ratio 数论+暴力

    题目: Description standard input/outputStatements Given an integer n, find out number of ways to repre ...

  5. dirname(_file_) DIRECTORY_SEPARATOR

    <?php echo __FILE__ ; // 取得当前文件的绝对地址,结果:D:\www\test.php echo dirname(__FILE__); // 取得当前文件所在的绝对目录, ...

  6. php 四种基础算法 ---- 快速排序法

    4.快速排序法 代码: function quick_sort($arr) {    //先判断是否需要继续进行    $length = count($arr);    if($length < ...

  7. KVC 实战浅析

    KVC 就是 key value coding,废话! 今天我们研究的是如何使用它! key value coding : 间接通过字符串类型的key取出对应的属性值 KVC的价值 1.可以访问私有成 ...

  8. tensorflow源代码方式安装

    本文介绍tensorflow源代码方式安装.安装的系统为 Ubuntu 15.04. 获取TensorFlow源代码 git clone --recurse-submodules https://gi ...

  9. jenkins tags

    List Subversion tags (and more) 参数设置 Tags filter ^((?!_ta_).)*$ 表示不含_ta_ Tags filtertrunk|(tags|bran ...

  10. startActivityForResult与onActivityResult

    androidActivity之间的跳转不只是有startActivity(Intent i)的,startActivityForResult(Intent intent, int requestCo ...