jQuery Interview Questions
1 .
How we can get the value of a radio button using Jquery?
When a radio button is selected addition check attribute is not added to it. You have to enter "checked".
 
Example :                                          
$(document).ready(function(){
    $("input[type='button']").on('click', function(){
       var radioValue = $("input[name='gender']:checked").val();
       if(radioValue){
          alert(radioValue);
       }
    });
}); 
2 .
How to validate phone number using jQuery?
We can use regex ([0-9]{10})|(\([0-9]{3}\)\s+[0-9]{3}\-[0-9]{4})
3 .
What are the element’s relative commonly used in jQuery API?
1. parent() and parents() are used to select an element’s parent or ancestors.
2. children() is used to select an element’s immediate children.
3. siblings() is used to select all of an element’s surrounding sibling elements.
4. prev() is used to select an element’s immediate preceding sibling.
5. next() is used to select an element’s immediate following sibling.
6. prevAll() is used to select all siblings coming before an element.
7. nextAll() is used to select all siblings coming after an element.
8. not() is used to remove elements from a selection using a selector.
9. eq() is used to zero in on a single element in a selection by providing its offset position within the selection offset from zero.
4 .
What do you mean by Tag name, Tag ID, Tag class?
Tag Name : Represents a tag name available in the DOM. For example $('p') selects all paragraphs <p> in the document.

Tag ID : Represents a tag available with the given ID in the DOM. For example $('#some id') selects the single element in the document that has an ID of some-id.

Tag Class : Represents a tag available with the given class in the DOM. For example $('.some-class') selects all elements in the document that have a class of some class.
5 .
How to Valid an email using JQuery?
To valid email id using JQuery create a separate function ValidEmail(). Pass the email id as a parameter. Using Regex we can valid the email id. Example shown below.
 
function ValidEmail(EmailID) {
var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (filter.test(EmailID)) {
return true;
}
else {
return false;
}
}
6 .
What is the use of JQuery $.extend method?
Using JQuery $.extend method we can merge the contents of two or more objects into the first object. The syntax is as follow.
 
var obj-0 = $.extend({}, obj-1, obj-2);
 
Let’s we have two array’s arr-i & arr-j. During development what I need is I want to merge arr-j values to arr-i. In this case jquery extend method helps.
 
$.extend( arr-i, arr-j );
 
But this is not recursive. To merge two objects recursively we need to pass the first parameter value true to extend method. As shown in below.
 
$.extend( true, arr-i, arr-j );
7 .
What is JQuery $.map method?
Jquery map method is used to translate items of an Array or object to new array of items. Let’s take an example.
 
var tempArray = { "name":"RamanaReddy", "age":30, "designation":"UI Developer" };
var realArray = $.makeArray( tempArray )
$.map( realArray, function( val, i ) {
// Do something
});