Trending February 2024 # Working Of Jquery Reference In Jquery With Examples # Suggested March 2024 # Top 9 Popular

You are reading the article Working Of Jquery Reference In Jquery With Examples updated in February 2024 on the website Cancandonuts.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested March 2024 Working Of Jquery Reference In Jquery With Examples

Definition of jQuery Reference

In Jquery, reference is defined as a set provided by jquery which contains jquery events used for triggering methods, selectors, and properties, which are defined for selecting and converting HTML elements provided few methods for handling events for such selections which when the events are triggered when the methods are executed and this jquery reference have the ability where to make the navigation (top, down, right and left) of the HTML elements along with supporting of jquery effects such as sliding or fading or showing or any kind of animations in the web pages using HTML elements are all defined and are provided by the jquery reference in Jquery.

Start Your Free Software Development Course

Working of Reference in jQuery Examples

In the below section let us take one by one element of the jquery reference that contains methods, events, effects, selectors, utilities, etc along with examples:

Events Example

Code:

#circle { width: 150px; height: 150px; border-radius: 50%; background-color: green; margin: 200px 200px 200px 200px; } });

Output:

jQuery Reference manipulation methods Example

Code:

$(document).ready(function () { $(‘p’).append(‘Educba ‘); }); div{ border: 2px solid; background-color:blue; margin: 5px 0 5px 0; font-size:20px; }

Output:

In the above program, we can see we are using append(), prepend(), after(), and before() method where we have added the content after the h1 element which shown in cyan color, then we are adding content before second div tag which is shown in yellow color, then we add the content at beginning of the paragraph which gives prepended paragraph and then the paragraph content is appended with the word “Educba” and prints complete sentence “Welcome to Educba”. There are many such methods used for constructing such web pages.

Selectors

In jquery, it provides the main function which is used only when we are using jquery codes as we know before writing jquery code we start with $ symbol so this is called as factory function which has the syntax as “$()” where we can pass any name or element name, id, class, etc of tags that are defined in the HTML structure.

Example

Code:

<script type = “text/javascript” #circle { width: 150px; height: 150px; border-radius: 50%; background-color: green; margin: 10px; } .educbaclass { margin:50px; border :10px solid; } }); $(“p”).css(“background-color”, “yellow”);

In the above program, we can see we have declared a div tag and defined with id name as “circle” so we are using the selector on div tags which has id. Similarly, we have also defined a class name for paragraph “p” and we can see in the above code we are printing that selected paragraph with different CSS styles which can be done not only by the CSS syntax in HTML structure but also using jquery selector and function CSS() on paragraph tag. Therefore there are many such selectors that are used in jquery reference such as selecting multiple elements, selecting all the elements of DOM using universal selector, etc.

In jquery reference, there are effects which are used for animation effects in web pages such as animate(), fadIn(), fadeout(), hide(), show(), etc. In traversing reference can be used for movement of elements such as up, down, right, left, etc.

Conclusion Recommended Articles

This is a guide to jQuery Reference. Here we also discuss the Definition and Working of jQuery Reference in jQuery with Examples along with different examples and its code implementation. You may also have a look at the following articles to learn more –

You're reading Working Of Jquery Reference In Jquery With Examples

Working Of The Jquery Param() With Examples

Introduction to jQuery param()

In jQuery, param() is a function defined as the Ajax method, which is used for representing the continuous string of an object or an array; while making the Ajax request, the URL can use these serialized or continuous string values for calling the request. In general, we can define-param() function as a function for converting to the continuous string from the provided elements internally and if in case any plain object is passed which would properties like name or value that contains the input elements along with these properties and this function has the options to disable globally by setting the traditional value to true.

Start Your Free Software Development Course

Working of the jQuery param() with Examples

In this article, we will see the param() function of jQuery, which is an Ajax method for making the Ajax request; we need to use these serialized string obtained after applying this function to the elements internally, which contain the return value as a continuous string of an array or object. In jQuery, the param() function is used by the URL for making the Ajax request by converting the elements into the continuous string as the output of this param() function, or we can say this function returns the serialized string representation of an array or plain object.

Let us see syntax and examples of how to use this function:

Syntax:

$.param(object, traditional_style)

Parameters:

Object: This parameter is used to specify the string or object that needs to be serialized. This parameter needs to be specified compulsory.

Traditional: This parameter is used to specify the serialization styles of param() function that is required to use or not the traditional shallow style, which is a Boolean value to be specified, and this parameter is optional.

This function returns the converted serialized string representation of an array or an object that is passed to this function.

Let us consider an example of how to declare the param() function.

Example #1

Code:

Educba Training Institute <script src= EDUCBA Jquery $(document).ready(function() { jqpmobj = new Object(); jqpmobj.Fullword = “EDUCBA “; jqpmobj.Firstword = “Jquery “; jqpmobj.Secondword = “Param() “; jqpmobj.Thirdword = “Function “; jqpmobj.Wordcolor = “Blue”; $(“div”).text($.param(jqpmobj)); }); });

Output:

In the output, we can see each word is separated by “%20&” because we are specifying both for Fullwords and single word spaces are replaced by this in the above output. So in the above code, we have passed the object “jqpmobj”, so we must specify any name or value properties, and here it is “Fullword” or “Firstword”, etc. So this param() function when objects are passed these names or values parameters are added to the URL string, which is dynamically modified with the history API.

Now we will see an example with creating three objects and to display the decoded object, which is done using decodeURIComponent() in the below code.

Example #2

$(document).ready(function() { var com_obj1= new Object ({ p: [ 7, 1, 6 ] }); var com_obj2= new Object ({ p: { q: 7, r: 1, s: 6}, t: [ 3, 9] }); var com_obj3 = new Object({ p: {u: 4, v: 4}, w:[2, 8] }); var x = decodeURIComponent( $.param(com_obj1)); $(“#p1”).text(x); var y = decodeURIComponent( $.param(com_obj2)); $(“#p2”).text(y); var z = decodeURIComponent( $.param(com_obj3)); $(“#p3”).text(z); }); });

Output:

In the above code, we can see we are using the decoseURIComponent(), which is used for decoding the objects so which is a bit complex so; in the above code also we can see we are creating 3 objects and the decoded codes are as shown in the above screenshot of the output.

Conclusion

In this article, we conclude that the jQuery provides a function called param(), which is used for representing the array of objects in a serialized way. In this article, we saw how to declare and use the param() function with syntax and examples. In this article, we also saw an example with the simple creation of the object, and then in another example, we also saw the creation of complex objects and decoding the objects using param() and decodeURIComponent() function.

Recommended Articles

This is a guide to jQuery param(). Here we discuss the introduction and working of the jQuery param() with examples, respectively. You may also have a look at the following articles to learn more –

How To Use .On And .Hover In Jquery?

jQuery- a popular JavaScript library used in simplifying web development tasks. It gives an easy-to-use syntax that simplifies coding and improves performance. Among the many features that jQuery provides, two of the most commonly used are .on() and .hover(). These methods allow to bind events to DOM elements and executing code when the events are triggered.

In this article, we will learn how to use .on() and .hover() in jQuery. We will see the different approaches to using the .on() and .hover() methods.

The .on() Method

The .on() method in jQuery is used in binding one or more events to a selected element. The method provides a flexible way to attach events to existing and dynamically created elements. The .on() method gives a lot of consistency to the API, and is recommended to use this method due to its simplifying process in the jQuery code base.

Syntax

Below is the syntax for using the .on() method in jQuery.

$(selector).on(event, childSelector, data, handler); Parameters

selector − the selector of the element(s) to which the event will be bound.

event − the event(s) to be bound to the selected element(s).

childSelector (optional) − a selector for child elements of the selected element(s) that should trigger the event.

data (optional) − additional data to pass to the event handler function.

handler − the function to be executed when the event is triggered.

$(document).ready(function() { }); });

Example 2: Binding Events to Dynamic Elements

The .on() method binds a blur event to the form on the page. This event is triggered when an input field loses focus. We specify the “input” selector as the second argument to the .on() method, which tells jQuery to only listen for blur events on input elements that are descendants of the form element. When a blur event is triggered, we use the $(this) keyword to get a reference to the input field that triggered the event, and use the .val() method to get its value. We then display the value in an alert box.

$(document).ready(function() { $(“form”).append(input); }); $(“form”).on(“blur”, “input”, function() { alert($(this).val()); }); });

Event Binding in .on() Method The .hover() Method

The .hover() method in jQuery is used in binding two events i.e. mouseenter and mouseleave event to a selected element. This method allows us to execute different codes when the user hovers over an element and when they move their mouse away from it.

The hover() method specifies two functions to run when the mouse pointer hovers over the selected elements.

Syntax

Below is the syntax for using the .hover() method in jQuery.

$(selector).hover(handlerIn, handlerOut); Parameters

selector − the selector of the element(s) to which the event will be bound.

handlerIn − the function to be executed when the user hovers over the element.

handlerOut − the function to be executed when the user moves their mouse away from the element.

Example: The Default Method

In the below example, we have used the $(document).ready() method to wait for the DOM to be fully loaded before executing the JavaScript code and also used the .hover() method to bind two events (mouseenter and mouseleave) to the div element on the page. Now, when the user hovers over the div, the background color is changed to violet using the .css() method. When the user moves their mouse away from the div, the background color is changed back to green.

div { width: 200px; height: 200px; background-color: green; border: 1px solid black; } $(document).ready(function() { $(“div”).hover(function() { $(this).css(“background-color”, “violet “); }, function() { $(this).css(“background-color”, “green”); }); });

Conclusion

The .on() and .hover() methods in jQuery are powerful tools that make it easier to bind events to DOM elements and execute code when those events are triggered. The .on() method provides a flexible way to attach events to existing and dynamically created elements, and the .hover() method allows us to execute different codes when the user hovers over an element and then moves their mouse away from it. By understanding the syntax and different approaches to use these methods, developers can create more dynamic and interactive web applications with ease.

Working Of Long Data Type In C++ With Examples

Introduction to C++ long

Web development, programming languages, Software testing & others

Working of long Data Type in C++

In this article, we will discuss the long data type in C++. The long data type is a basic numerical signed and unsigned integer type which is used for specifying the storage size and location of variables or constants that are used in programs that can hold values as long as a single 64-bit signed (numbers can be either positive or negative) integer type or unsigned (only positive numbers) integer type that is long can store 263 with one bit for the sign. This long type is used to store large values that are equivalent to the long int type. These long type variables can be used with double variables also as it can be used as a long int. In C++ there is also another data type where it can help us store numbers larger than long and such variables can be stored with data type long long which is created twice using long data type but this long long type modifier can only be used with the int data type. In C++, there are specific literals provided to these data types such as for long type we use either “L” or “l” is used to identify long literal by suffixing these alphabets and for long long int we suffix with “LL” literal which are used for signed and if we want to indicate unsigned long then suffix wit “UL” and unsigned long long int then we have to suffix with “ULL”.

Examples of C++ long

Now in the below section let us see how to declare long variables in a program.

Example #1

Code:

using namespace std; int main() { long a = 4564667; long int b = 4564667; cout <<“Program to demonstrate long in C++” <<“n”<<endl; cout <<“The value of variable with long variable a is  “<< a <<“n”<< endl; cout <<“The value of variable with log int variable b is “<< b << “n”<<endl; cout <<“The size of long variable a is ” << sizeof(a) <<“n” << endl; cout <<“The size of long int variable b is “<< sizeof(b) <<“n” <<endl; return 0; }

Output:

In the above program, we can see we have created a variable with long type “a” and another variable “b” with long int type these both have the same value so we can say long long and long int type is the same and we also can see we are declaring the size of the variables which can be done using sizeof() function. So we can say the size of long and long int have the same size that is 8.

Example #2

Code:

using namespace std; int main () { long p, q; long long res; p = 5456943859; q = 254689; res = p * q; cout<<“Program to demonstrate long long type in C++” <<“n”<<endl; cout<<“The long type varaibles p ” << p << ” and q ” <<q << “is n”<<endl; cout <<“The product of two long variables p*q = “<< res <<endl;; cout<< sizeof(res)<<endl; return 0; }

Output:

In the above program, we can see we have declared two long variables p and q and we are trying to find the product of these two variables which will be a very large value so we are declaring the variable “res” which will be the long long type which can store large value than long type. So in the above screenshot, we can see the output, and also we can see a size of long long variable “res” which prints 8 and the product value is 1389823574504851.

Example #3

Now we will see a sample example of using literals for long unsigned and signed data types.

using namespace std; int main () { long p = -5456943859L; long z = 8647627343UL; long long r = 1389823574504851LL; cout<<“Program to demonstrate long long and long type literals in C++” <<“n”<<endl; cout<<“The long type varaibles p literal is  ” << p <<“n”<<endl; cout<<“The long type variable z literal of unsigned long variable is “<<z <<“n”<<endl; cout<<“The long long type of variable r literal is = “<< r <<endl; return 0; }

Output:

In the above program, we can see we have declared a long variable “p” with value and we have suffixed it with “L” and we have also declared long long type variable “r” and we have suffixed it with “LL”. In the above program, we have seen we have p value suffixed with L as “5456943859L” and r variable which is the long long type with value 1389823574504851LL where we can see p and r are signed long variables. So the variable “z” is also a long type but it is unsigned so it can have only a positive number which can be seen in the above screenshot.

Conclusion

In this article, we can conclude that the long type variable in C++ is a type of data type which is used for storing the values that are as large as 64-bit values, and in C++ it also provides a data type long long which is another data type to store values larger than the long type which means it can hold the value twice of long type. In this article, we have seen a simple example of how to declare the long type variables which is equivalent to long int in C++. In this article, we also saw the example of long long type variables along with the literals which are used by suffixing it with value to indicate the signed or unsigned long type variables.

Recommended Articles

This is a guide to C++ long. Here we also discuss the introduction and working of long data type in c++ along with different examples and its code implementation. You may also have a look at the following articles to learn more –

Learn How To Run Jquery Codes & Attribute Methods

Introduction of jQuery Attributes

jQuery is a library of JavaScript, which we can use in an html code. The need for jQuery in an html is to easy use JavaScript in that and to make a website more attractive and interactive. Actually, jQuery is a JavaScript toolkit which is having various built-in functions by writing less code, so the motto is “ write less, do more “. In this topic, we are going to learn about jQuery Attributes.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

The various important features of jQuery are –

DOM manipulation– To select DOM elements and modify DOM elements content with open source cross-browser selector engine, which is called Sizzle, is made very easy by The jQuery.

AJAX Support– The AJAX (Asynchronous JavaScript and XML ) is used to render the website page; with the AJAX technology, we can create a responsive and feature-rich site. The jQuery helps to develop the AJAX technology in html code.

Animations− The various built-in animation effects provided by jQuery which can be use on websites.

Lightweight− The good feature of jQuery is it is lightweight. It is just 19KB in size.

Cross Browser Support− The cross-browser is another important feature of jQuery, which supports various browsers Chrome, IE 6.0+, FF 2.0+, Safari 3.0+, and Opera 9.0+.

Latest Technology− The latest technology, CSS3 selectors, basic XPath syntax, and so are supported by jQuery.

The prerequisites for jQuery Attributes –

How to Run JQuery Codes?

The jQuery can be written and run two ways as –

CDN Based Version− In this, we include the jQuery library into an HTML code. The jQuery include directly from CDN ( Content Delivery Network ).

Example #1

We write an HTML example program in which we include the jQuery library as in the below example −

<script type = “text/javascript” $(document).ready(function() { document.write(” Hello! from jQuery code “); });

The output of the above program is 

When the event is generated, all the code which is inside of the $(document) .ready () function is executed, or the entire component or in other word elements loaded before DOM.

Next, the basic components which we can modify when it comes to DOM elements are the properties and attributes of the elements assigned value. So let’s see how we can modify the attributes of the elements using jQuery.

Some of the element properties or attributes that are common uses based on the element are – className, title, tagName, id, rel, href, src, alt, align, id, and so all.

Let’s take the example of the html image element and its attribute −

The above element tag name is img, and the attributes are class, id, src, alt, and title; each attribute is assigned some value. These attributes value we can get and change by using jQuery. The jQuery provides two methods, attr()  and attr(name, value), to get the attribute value and to set the attribute value of a matched element, respectively.

The syntax of using the attr() method is different based on the purpose of use.

To get the value of an attribute –

$(element).attr(attribute);

To set the attribute and value –

$(element).attr(attribute, value);

To set attribute and value using a function –

$(element).attr(attribute, function(index, currentvalue));

To set multiple attributes and values –

$(element).attr({attribute : value, attribute : value, attribute : value });

To get the Attribute Value of a matched elements –

We can get the attribute value of an element by using the function attr(attribute) from the first element in the matched set or set attribute values onto all matched elements.

Example

Example #2

<script type = “text/javascript” $(document).ready(function() { var title = $(“h1”).attr(“title”); $(“#id_div”).text(title); });

The output of the above program is 

Example #3

<script type = “text/javascript” $(document).ready(function() { var id = $(“h2”).attr(“id”); $(“#id_div”).text(id); });

To set the Attribute Value of matched elements –

We can set the attribute value of an element by using the function attr(attribute, value) onto all elements in the matched set or set attribute values by using the passes value.

Consider an example which set the src attribute of an image tag to a correct location −

Example #4

<script type = “text/javascript” $(document).ready(function() { $(“#imgid”).attr(“src”, “altimage.png”); });

The output of the above program is 

Example #5

<script type = “text/javascript” $(document).ready(function() { $(“h1”).attr(“align”, “center”); }); });

The output of the above program is 

Next, we see how to apply different styles to the matched elements using jQuery-provided method addClass(classes). We can apply not only a single style class but can apply multiple classes just separated by space.

Example #6

<script type = “text/javascript” .font { color : green; } .highlighht { background : yellow; } $(document).ready(function() { $(“h1”).addClass(“font”); $(“#h2id”).addClass(“highlighht”); });

The output of the above program is 

Example #7

<script type = “text/javascript” .font { color : green; } .highlighht { background : yellow; } $(document).ready(function() { $(“h1”).addClass(“font”); $(“h1”).attr(“align”, “center”); $(“#h2id”).addClass(“highlighht”); });

The output of the above program is –

Attribute Methods of jQuery

Some of the jQuery attribute methods which modify the DOM elements attributes and properties are –

attr( properties ) – This method sets attribute value to all matched elements. Above, we have seen an example of this; now we see this method to set multiple key-value properties.

Ex : $( "img" ).attr({ alt : " Image not available", src : "img.png", title : "Image jQuery"});

attr( key, fn ) – This method sets a single attribute or property to a value on all matched elements.

Ex : $("h1").attr("align", "center");

removeAttr( name ) – This jQuery method is used to remove an attribute from all matched elements.

Ex : $("h1"). removeAttr ("align", "center");

hasClass( class ) – This jQuery method used to find a specified CSS class is applied on any one of the matched elements; if yes, then it returns true otherwise false.

Ex : $("p#ptagid"). hasClass ("font ");

addClass( class ) – This jQuery method used on elements to apply the specified class if it is not applied.

Ex : $("h1").addClass("font");

removeClass( class ) – This jQuery method used on elements to removes specified classes or classes.

Ex : $("p#ptagid"). removeClass ("font ");

html( ) – This jQuery method used to get first html tag or matched element.

Ex : $("h1").html( );

text( ) – This jQuery method used to get the text contents of all matched elements, except form and input elements.

Ex : $("#id_div").text(title);

val( ) – This jQuery method used to get the value of input from the first matched element.

Ex : $("#inputid").val( ); Conclusion – jQuery Attributes

jQuery is a JavaScript library. jQuery allows performing tasks such as DOM manipulation, event handling, AJAX Support, Animations, Lightweight, Cross Browser Support, Latest Technology. Use jQuery in html code two ways: Local Installation, and another way is CDN Based Version.

The DOM element attributes such as className, title, tagName, id, rel, href, src, alt, align, id and all can be fetch and set by using the jQuery provided method attr()  and attr(name, value), respectively.

The different jQuery method is

attr( properties )

attr( key, fn )

removeAttr( name )

removeClass( class )

toggleClass( class )

html( )

val( )

Recommended Articles

This is a guide to jQuery Attributes. Here we discuss the important features of jQuery and how to run jQuery codes with the examples and outputs. You may also have a look at the following articles to learn more –

Working Of Methods Inwith Examples

Introduction to chúng tôi Methods

Vue.js methods are defined as a function to perform certain actions whenever the user is needed and the method is associated with a Vue instance as the method is similar to function like in other programming languages. In chúng tôi methods are defined using the “method” name property before declaring or using it as a method in the chúng tôi app code, in simple words we can say methods are function associated with an instance which are defined inside the method property, methods are usually defined similarly to as declaring “def” in the python for defining methods or functions and in chúng tôi we use “method” property.

Start Your Free Software Development Course

Working of Methods in chúng tôi with Examples

Here, we will discuss the method declaration in chúng tôi In this, methods are defined or declared inside the method property which means we have to write “method” before writing the method body. In chúng tôi methods are useful for connecting functionality to directives for handling the events. This can also be said to define any piece or small code of logic we need to use methods and this logic can be used for any other function or in the rest of the program. So we can also call a method inside a lifecycle hook also which is also another way of using methods in Vue.js.

Let us demonstrate how to declare methods in chúng tôi with the below syntax and example.

Syntax:

new Vue({ e1: '#app' ……. methods: { piece of code or logic } )}

In the above, we can see the syntax for declaring methods in the chúng tôi code snippets. In this, we can see we have declared method property to define or declare methods that will have a piece of code or logic within the method property which we want it to call in another method or rest.

Example #1

So let us consider a simple example for demonstrating the use and declaration of methods in Vue.js.

Html File:

{{ message }}

Vue js App Code:

new Vue({ el: '#app', data: { message: 'information' }, methods: { func() { this.message = 'Educba Training Institute'; } } });

Output:

Now we know whenever we need some actions or events to be performed then these methods are the easiest and useful ways to use in such cases. To do this a venue provides a directive called v-on which can be used to handle the events.

In chúng tôi accessing the date or message from the method is also simple as we saw in the above program where data to be accessed it written as the value of “message” which is information and this is accessed inside the method using “this. message” whereas we don’t need to use “this.data. message” which would rather throw an error and hence chúng tôi provides transparent binding with the use of method property. And in the above program, we also saw they are closely interlinked to the events and hence in chúng tôi the methods are mostly used as event handlers.

In chúng tôi methods are also used to handle inline js statements because where instead of binding to the method name we can use inline statements using methods.

Example #2

Html file:

Vue js Code:

new Vue({ el: '#methodapp', methods: { disp: function (info) { alert(info) } } })

Output:

Conclusion

In this article, we conclude that the concept of the method in chúng tôi is similar to that of functions concepts in other programming languages. In this article, we saw how to declare methods using “method” property before writing the function logic code and we also saw how we have used methods as an event handler using v-on directive along with which we also saw how it used for binding inline javascript statements instead of directly binding with the method names.

Recommended Articles

This is a guide to chúng tôi Methods. Here we discuss the introduction and working of methods in chúng tôi with examples respectively. You may also have a look at the following articles to learn more –

Update the detailed information about Working Of Jquery Reference In Jquery With Examples on the Cancandonuts.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!