document.getElementById("elementId").style.display="none"

在JavaScript中用于隐藏元素.但是在jQuery中,

$("#elementId").hide();

is used for the same purpose. Which way is more efficient? I have seen a comparison between two jQuery function .hide() and .css("display","none") here.

But my problem is whether pure JavaScript is more efficient than jQuery?

推荐答案

谈到效率:

document.getElementById( 'elemtId' ).style.display = 'none';

jQuery对其.show().hide()方法所做的是,它记住元素的last state.这有时会派上用场,但既然你问的是效率,这在这里就无关紧要了.

Jquery相关问答推荐

在Click事件上将焦点设置为Kendo UI网格列筛选器文本框

如何根据另一个 radio Select 并切换?

在 Laravel 中使用 jQuery post 按相关值过滤 Select 选项,如何显示从控制器返回的数据?

如何在jQuery中判断粘贴剪贴板中字母输入的增加/减少

$ 不是函数 - jQuery 错误

如何使 Bootstrap 轮播滑块使用移动左/右滑动

如何在 jquery 中包含 !important

如何知道所有ajax调用何时完成

jQuery/JavaScript 碰撞检测

jQuery .get 错误响应函数?

为特定请求禁用 ajaxStart() 和 ajaxStop()

如何使用 jquery 正确格式化货币?

JSON 到字符串变量转储

在不使用提交按钮的情况下触发标准 HTML5 验证(表单)?

AngularJS + JQuery:如何在 angularjs 中获取动态内容

带有 jQ​​uery 的饼图

如何通过javascript数组中的键和值查找对象的索引

Jquery live() 与委托()

在jQuery中,当它们都具有相同的名称时,如何获取单选按钮的值?

使用 Chosen 插件更改 Select 中的 Select