jquery quetions

What is the purpose of ‘this’ operator in JavaScript?

JavaScript famous keyword this always refers to the current context.
———————————————

Global Variables − A global variable has global scope which means it is visible everywhere in your JavaScript code.

Local Variables − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.

Which type of variable among global and local, takes precedence over other if names are same?

A local variable takes precedence over a global variable with the same name.

——————————————————

pop() : built-in method removes the last element from an array and returns that element
————————————————–
length() : built-in method returns the length of the string

———————————————-
reverse() :  built-in method reverses the order of the elements of an array
———————————————–
sort() : built-in method sorts the elements of an array
———————————————–
substr() : built-in method returns the characters in a string beginning at the specified location
————————————————
toLowerCase() : built-in method returns the calling string value converted to lower case
toUpperCase()
————————————————

select multiple elements using jQuery?

$(‘E, F, G’)

—————————————

attributes of an element using jQuery?

The attr()

set attributes of an element using jQuery?

The attr(name, value)

—————————————-

How can you apply a style on an element using jQuery?

The addClass( classes )

————————————

remove an attribute from each of the matched elements using jQuery?

The removeAttr( name )
———————————-
specified class is present on at least one of the set of matched elements using jQuery?

The hasClass( class )

————————————
specified class if it is not present, remove the specified class if it is present using jQuery?

The toggleClass(class)


Question : What is selectors? How many selectors are in jquery?

Check this link : https://www.w3schools.com/jquery/jquery_ref_selectors.asp

checks the current selection against an expression using jQuery?

The is( selector )
————————————

select a subset of the matched elements using jQuery?

The slice(selector)
————————————–

add more elements, matched by the given selector, to the set of matched elements using jQuery?

The add( selector )

———————————————-

The .detach() and .remove() methods are the same, except that .detach() retains all jQuery data associated with the removed elements and .remove() does not. .detach() is therefore useful when removed elements may need to be reinserted into the DOM at a later time

.empty(): This method removes all the child element of the matched element where remove() method removes set of matched elements from DOM.

.remove(): This method takes elements out of the DOM. Use .remove() when you want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed
—————————————

 

append() : jQuery object to insert at the end of each element in the set of matched elements.

<h2>Greetings</h2>
<div class="container">
<div class="inner">
Hello
<p>Test</p>
</div>
<div class="inner">
Goodbye
<p>Test</p>
</div>
</div>
You can also select an element on the page and insert it into another:

Example :    $( ".container" ).append( $( "h2" ) );

Output :

<div class="container">
<div class="inner">Hello</div>
<div class="inner">Goodbye</div>
<h2>Greetings</h2>
</div>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s