Saturday 4 February 2017

JQuery interview questions Part 1

Ques:  What is Jquery?
Answer: 
jquery is a lightweight open source JavaScript library. it is a fast & cross-platform JavaScript library which simply the client-side scripting of HTML. it also simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.


Ques: What are the advantages of jquery?
Answer: 
  •  It is light weight and fast  as compared to other java script frameworks.
  •  It is Cross-browser compatibility and Open source library
  •  DOM manipulation.
  •  AJAX Support.
  •  Animation and cool Effect.
  •  Easy to Use and more flexible.
  •  Expand the functionality using custom plugins.
  •  Provide Jquery user interface.

QuesWhat  is syntax of jquery using in page and what is document ready function ?
Answer:
<script language="javascript" >

         $(document).ready(function(){    
         alert("document is ready");
});
</script>

This is to prevent any jQuery code from running before the document is finished loading.
It is good practice to wait for the document to be fully loaded and ready before working with it.


Ques:What are the types of selectors in jquery ?
Answer:
There are 3 types of selectors in Jquery
1. CSS Selector
2. XPath Selector
3. Custom Selector


Ques:How many types of selectors in jQuery?
Answer:
The list of types of selectors in Jquery as .

1. Universal Selector -Selects all elements as $("*")
1. ID Selector - Selects the element with the id as $("#username")
2. Class Selector - Selects the element with the class name as (".students")
3. Element Selector - Selects the element using its type. For example if the element is a paragraph
4. Animated Selector -Select all elements that are in the progress of an animation at the time the selector is run.
5. Button Selector -Selects all button elements and elements of type button.
6. Attribute Selector -It is used to select elements based on its attribute value.


Ques: What are multiple selectors in jQuery?
Answer:
jQuery supports multiple selectors.it specify any number of selectors to combine into a single result.
ex : $('.dvstyle', '.bar', '#divID').this selector find all element which css is 'dvstyle' and 'bar'  and Id of is divID.


Ques: What are the effects methods used in jQuery ?  Explain with example.
Answer:
These are some effects methods used in jQuery:
show()
hide()
toggle()
fadeIn()
fadeOut()

show()
ex:
<script>
 $(document).ready(function()
  {
    $("#show").click(function(){
        $("p").show();
    });
});
</script>
<button id="show">Show</button>
<p>This is a paragraph content.</p>

hide()
ex:
<script>
 $(document).ready(function()
  {
   $("#hide").click(function(){
        $("p").hide();
    });
});
</script>
<button id="hide">Hide</button>
<p>This is a paragraph content.</p>

toggle()
ex:
<script>
 $(document).ready(function()
{
  $("button").click(function(){
      $("p").toggle();
});
});
</script>

<button>Toggle button </button>
<p>This is a paragraph content.</p>

fadeIn()
ex:
<script>
$(document).ready(function()
   {
       $("button").click(function(){
        $("#div1").fadeIn();      
    });
});
</script>

<button>Click to fade </button>
<div id="div1"></div>

fadeOut()
ex:
<script>
$(document).ready(function()
   {
    $("button").click(function(){
        $("#div1").fadeOut();      
    });
});
</script>

<button>Click to adeOut </button>
<div id="div1"></div>

No comments:

Post a Comment

Thank you for comment