Showing posts with label jQuery Interview Questions. Show all posts
Showing posts with label jQuery Interview Questions. Show all posts

Tuesday 7 April 2015

jQuery Interview Questions and Answers for 2 Year experienced

jQuery Interview Questions and Answers for experienced


Question: How to select all the images of a div tag?
Use below of code snippets
$('div.mydiv').find('img');
OR
$('div.mydiv').children('img');


Question: How to get the value of selected checkbox?
Get the radio button value by button NAME
$("input[name='radioButtonName']:checked").val();
Get the radio button value by button CLASS
$('.radioButtonClass:checked').val();


Question: How to get the value of selected checkbox?
Get the checkbox value by NAME
$("input[name='checkboxName']:checked").val();
Get the checkbox value by CLASS
$('.chekboxClass:checked').val();


Question: How to check, If element exist OR not?
Check the existence of element By ID
if($('#mydivId').length )){
    //console.log('Element exist);
}else{
//console.log('Element does exist);
} 

Check the existence of element By CLASS
if($('.mydivClass').length )){
    //console.log('Element exist);
}else{
//console.log('Element does exist);
} 


Question: How to select elements which have two classes?
Just write the selectors together without spaces, to select the elements having two classes?
myDivClass1$('#mydivId.myDivClass1.c.myDivClass2').val();
It will get all the elements, which have div with mydivId (ID), div with myDivClass1 (Class) and div with myDivClass2(class).


Question: How to disabled a button?
Disabled the button by ID
$("input#myDivId").prop('disabled', true);

Disabled the button by CLASS
$("input#myDivClass").prop('disabled', true);


Question: How to change the anchor tag's href?
Change the href value by ID
$("a#myATagId").attr("href", "http://www.web-technology-experts-notes.in/p/sitemap.html");
Change the href value by CLASS
$("a.myATagClass").attr("href", "http://www.web-technology-experts-notes.in/p/sitemap.html")


Question: How to set the cookie with jQuery?
jQuery core do not have cookie functions. For this, we can include jQuery cookie plugins and its really make the cookie handling very easy.

Download Cookie plugin from Below URLs.
http://plugins.jquery.com/cookie/
Set the cookie using plugin.
$.cookie("cookieName", "cookieValue", { path: '/', expires: 7 }); 

Get a cookie using plugin.
$.cookie("cookieName");

Delete the cookie.
$.removeCookie("cookieName");



Question: How to update the HTML of container?
Update the container with using ID
$('div#myDivId').html('this is new updated html tag.');

Update the container with using class
$('div.myDivClass').html('this is new updated html tag.');



Question: How to get the HTML of container?
Get the container's value with using ID
$('div#myDivId').html();

Get the container's value with using class
$('div.myDivClass').html();



Question: How to distinguish between left and right mouse click with jQuery on paragraph tag?
$('p#myParagraphId').mousedown(function(event) {
    switch (event.which) {
        case 1:
            //alert('Left Mouse.');
            break;
        case 2:
            //alert('Middle Mouse .');
            break;
        case 3:
           // alert('Right Mouse .');
            break;
        default:
            //alert('Else click');
    }
});


Question: How to get the hash values of URL?
As we know, we can't get the hash values with using PHP. but we can get the hash values with javaScript.
if(window.location.hash) {
  // hash values
}



Question: How to change the image source using jQuery?
Change the image source with using ID
$('img#myImageId').attr('src','http://mydomain.com/newimage.png');

Change the image source with using Class
$('img.myImageClass').attr('src','http://mydomain.com/newimage.png');




Sunday 4 January 2015

Front End Developer Interview Questions and Answers

Front End Developer Interview Questions and Answers

Question: What is the importance of the HTML DOCTYPE?
DOCTYPE is an instruction to the web browser about what version of the markup language the page is written. Its written before the HTML Tag. Doctype declaration refers to a Document Type Definition (DTD).


Question: Explain the difference between visibility:hidden; and display:none?
Visibility:Hidden; - It is not visible but takes up it's original space.
Display:None; - It is hidden and takes no space.


Question: How do you clear a floated element?
clear:both


Question: What is the difference between == and === ?
== is equal to
=== is exactly equal to (value and type)



Question: What is a java script object?
A collection of data containing both properties and methods. Each element in a document is an object. Using the DOM you can get at each of these elements/objects.



Question: Describe what "this" is in JavaScript?
this refers to the object which 'owns' the method.



Question: What is a closure?
Closures are expressions, usually functions, which can work with variables set within a certain context.


Question: How to use a function a Class?
function functionName(name) {  
    this.name = name;
}
// Creating an object
var functionName = new functionName("WTEN");  
console.log(functionName.name);  //WTEN



Question: What is Difference between null and undefined?
null is an object with no value. undefined is a type.
typeof null; // "object"  
typeof undefined; // "undefined"  



Question: What is the difference between HTML and XHTML?
HTML is HyperText Markup Language used to develop the website.
XHTML is modern version of HTML 4. XHTML is an HTML that follows the XML rules which should be well-formed.


Saturday 3 January 2015

How to Add attribute in A-Tag using jQuery

How to Add attribute in A-Tag using jQuery


Following is HTML:
<div class="links">
<a href="http://www.web-technology-experts-notes.in/2014/12/bootstrap-interview-questions-and-answers-for-experienced.html">link1</a>
<a href="http://www.web-technology-experts-notes.in/2014/12/seo-interview-questions-and-answers.html">link2</a>
</div>


Output Should be:
<div class="links">
<a href="http://www.web-technology-experts-notes.in/2014/12/bootstrap-interview-questions-and-answers-for-experienced.html" target="_blank">link1</a>
<a href="http://www.web-technology-experts-notes.in/2014/12/seo-interview-questions-and-answers.html" target="_blank">link2</a>
</div>



Following are Simple ways to do this Using jQuery.
$(document).ready(function() {
    $('div.links p a').attr('target', '_blank');
});

We can also add custom attribute in any html tag.





Monday 27 October 2014

Lightbox vs Fancybox

Lightbox vs Fancybox

Lightbox: It is a lightweight jQuery plugin  used for showing images in overlay on the website.

Following are feature of Lightbox plugin.
  1.     Show image in overlay.
  2.     Show the Title of image in Overlay.
  3.     Show image gallery in overlay with "Left", "Right" Button.
  4.     In Image gallery, It support image movement with "Left" & "Right" keys.
  5.     Open Iframe in overlay does not support.
Demo & Downloadhttp://lokeshdhakar.com/projects/lightbox2/ 




Fancybox: It is jQuery plugin used for displaying images, videos (like youtube) on  iframe and map etc in overlay on the website.

Following are feature of  Fancybox plugin.
  1.     Show image in overlay.
  2.     Show the Title of image in Overlay.
  3.     Show image gallery in overlay with "Left", "Right" Button.
  4.     In Image gallery, It support image movement with "Left" & "Right" keys.
  5.     Open Iframe in overlay - You can play youtube video in overlay.
  6.     Support Ajax Processing Data.
  7.     Play SWF Files in overlay.
  8.     Google Map in Iframe.
  9.     Support callback function when open pages in overlay.
  10.     Handling "Not existing URL/Image" by plugin itself.

Saturday 8 June 2013

Pending Interview Questions and Answers

Who is the Father of PHP?
Rasmus Lerdorf


Which programming language does PHP resemble to?
PHP resemble to pearl and C


How can we create a database using PHP and MySQL?
We can create MySQL database in php with the use of
mysql_create_db ("db_name");


Is variable name case sensitive?
Yes, In PHP variable name case sensitive. We cannot start a variable with number like $777name as a valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.


How can we execute a php script using command line?
Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program.


Differentiate between in_array() and array_search() in php?
in_array : Checks if a value exists in an array. array_search() : Searches an array for a given value and returns the corresponding key if successful.


How do you call a constructor for a parent class?
parent::constructor($value);


How to delete file in PHP ?
unlink($filename);


How to delete variable in PHP ?
unset($variable);


What is the urlencode and urldecode in php ?
Returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs.


What is the use of the function htmlentities?
htmlentities Convert all applicable characters to HTML entities This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.


Differentiate between strstr and stristr in php?
strstr() and stristr both are used to find the first occurence of the string only difference is stristr( ) is case insensitive.


How can we know the total number of elements of Array?
sizeof($array);
count($array);


How to secure your website?
  1. Validate Input.
  2. Use Auth & ACL.
  3. Protect my Session ID
  4. Preventing Cross Site Scripting (XSS) flaws
  5. SQL injection vulnerabilities
  6. Turning off error reporting and exposing to the site for hackers
  7. Protect secure data of website


What is PHP configuration file called?
php.ini.


What is a persistent cookie?
A persistent cookie is a cookie which is stored in a cookie permanently on the browser's computer. By default, cookies are created as temporary cookies which stored only in the browser's memory. When the browser is closed, temporary cookies will be erased automatically.


What are non-key columsn in database?
Answer: A non key attribute in sql server is a columns which can not be used to identify a record uniquely for example name or age columns in customer table