Friday 31 October 2014

Javascript Vs Jquery

JavaScript: A powerful language in web development
JavaScript is a scripting language that is used to add interactivity to our web pages. It is one of the three core technologies alongside HTML and CSS which are used to create web pages. 
JavaScript is supported by all the web browsers and the web browsers have a built-in JavaScript engine to identify JavaScript code and work with it. Thus, JavaScript is majorly a client-side language.

jQuery: A library developed from JavaScript
jQuery is a library of JavaScript which is built from it. It is the most popular JavaScript library. jQuery is free, an open-source library, licensed under the MIT License. This has a powerful feature of cross-browser compatibility. It can easily handle cross-browser issues that we can face with JavaScript. Thus many developers use jQuery to avoid cross-browser compatibility issues.

Why jQuery is created and what are the special capabilities of jQuery?
In JavaScript, we have to write a lot of code for basic operations while with jQuery the same operations can be done with a single line of code. Therefore developers find it easier to work with jQuery than with JavaScript.

DOM Traversal and Manipulation

In JavaScript:

We can select a DOM element in JavaScript using the document.getElementById() method or by using the document.querySelector() method.

var mydiv = document.querySelector(“#div1”);
//Or
document.getElementById(“#div1”);

In jQuery:

Here, we will have to only use the $ symbol with the selector in brackets.

$(selector)

$("#div1") – The selector is an id ‘div1
$(".div1") – The selector is a class ‘div1
$("#P") – The selector is the paragraph in the Html page

Adding styles in JavaScript:
document.getElementById ('myDiv').style.backgroundColor="#FFF"

Adding styles in jQuery:
$('#myDiv').css (‘background-color','#FFF');

0 comments:

Post a Comment

Topics

ADFS (1) ADO .Net (1) Ajax (1) Angular (43) Angular Js (15) ASP .Net (14) Authentication (4) Azure (3) Breeze.js (1) C# (47) CD (1) CI (2) CloudComputing (2) Coding (7) CQRS (1) CSS (2) Design_Pattern (6) DevOps (4) DI (3) Dotnet (8) DotnetCore (16) Entity Framework (2) ExpressJS (4) Html (4) IIS (1) Javascript (17) Jquery (8) Lamda (3) Linq (11) microservice (3) Mongodb (1) MVC (46) NodeJS (8) React (11) SDLC (1) Sql Server (32) SSIS (3) SSO (1) TypeScript (1) UI (1) UnitTest (1) WCF (14) Web Api (15) Web Service (1) XMl (1)

Dotnet Guru Archives