jQuery Inheritance
hartsean
Posted on March 23, 2020
Since the arrival of jQuery in 2005, client side web applications have grown substantially more dedicated to taking advantage of the newly popularized paradigm wherein javascript based interactions with the user trigger the modification of data presented on the screen.
Today, 75% of websites on the internet are using jQuery and practically all of the most popular websites in the world are heavily reliant on Javascript to perform their functions. Inheritance has been a concept so infused with classical object oriented programming that it doesn't at first glance appear to go hand in hand purely functional javascript and the realities of client side architecture. But, Inheritance is by nature a proven characteristic of data models that are widely used and distributed to perform required tasks more efficiently and sustainably in a given environment or across networks.
Here are some example of how jQuery uses inheritance to expand its usefulness as client side manipulator of data.
$(document).ready(function(){
function Character(name, job) {
this.name = name;
this.job = job;
}
Character.prototype.sayHey = function () {
return this.name + " says hello";
};
var sean = new Character("sean", false);
sean.sayHey();
$(".test").append("
Hello World!")$(".tClass").css("color", "green");
$("input").focus(function(){
$(this).css("background-color", "cornflower-blue");
});
});
Posted on March 23, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.