7 ms·
jQuery API is not pretty
by dotborg 14y ago
jQuery API is not pretty
- freepipi 14y agoI am a c developer, now I want to learn jQuery , but its syntax seems so weird to me, Vanilla JS looks more comfortable to me , one questions, does it supported by webkit?
- pooriaazimi 14y agoI'm sorry. I don't know if you're joking or are serious. But if you're a C programmer and have no experience with JS I guess it must be really easy to be fooled by this "joke". Some JS people (the ones usually with a long beard) hate how kids use frameworks like jQuery and this site is an attempt at telling them "The vanilla JS, i.e. the standard language that all browsers use and your cool jQuery leverage under the hood, is quite capable these days. Use it". They are not quite right, but aren't quite wrong either (IMO). You'll be a dreadful JS programmer if you only know jQuery. JS is sooo different from C (and Java) that if you don't know the core language everything you'll do will be wrong. For starter: there's no block scope. Only function scope. Every JS programmer should read "JavaScript: The Good Parts" by Douglas Crockford cover to cover - before learning jQuery.
- ams6110 14y agothere's no block scope. Only function scope. There is global scope as well, and it's (unfortunately in most cases) the default.
- MatthewPhillips 14y agoAlso there is block scope. let { ... }
- evilduck 14y agoAFAIK, let is a Mozilla only feature.
- freepipi 14y agoI want to learn something about jQuery,because recently I need to develop an application which use webkit. It has a feature that need to highlight some special words. After search in the internet, I found the jQuery can 'easily' do that. But the syntax of jQuery make me headache, then I happened to see this article. Thank you very much , I am very appreciate for your advice:)
- emehrkay 14y agoLook at other libraries. I cant beat the MooTools drum loud enough.
- dag11 14y agoI'll take $('p').text('Hello.') over for (var p in document.getElementsByTagName('p')) { p.innerHTML = 'Hello.'; } any day!
- aaronblohowiak 14y agoinnerHTML is an easy one, try setting an attribute -- you have to create a new attribute node, set its value and then add that to the element..
- mibbitier 14y agosetAttribute()?
- aaronblohowiak 14y agoIE8 =(
- masklinn 14y ago> you have to create a new attribute node, set its value and then add that to the element.. Erm... no you don't: http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-F68F082 http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-F68F082
- aaronblohowiak 14y agoIE8 =(
- gildas 14y agoYou should set the node property instead (e.g. standard textContent or innerText). It will work everywhere.
- dotborg 14y agodid you ever try to debug your pretty jquery karate? ps. second example is not valid, in Vanilla JS you do it like this: document.getElementsByTagName('p').filter(function(el) { el.innerHTML = 'Hello.'; });
- aaronblohowiak 14y agoCompared to the dom api, it is very pretty.
- deleted 14y ago[deleted]