1.What is wrong in this HTML code snippet: <img alt="Alt Text" title="title" class="preety" id="img1"> ?
The HTML tag doesn't have the closing </img>
The HTML tag has no "src" attribute and it doesn't have the closing </img>
The HTML tag has no "src" attribute
2.Which of the following jQuery code snippets have the effect of changing the background color of "div" elements in a web page ?
jQuery("div").style("background", "#000")
jQuery("div").setStyle("background", "#000")
jQuery("div").css({background: "#000"})
3.By using CSS, how do you change the background of an element (.changeme), from transparent to #DDD, when the user hovers on a parent element (.parent) but not on the element itself ? The HTML is: <a href="#" class="parent">Some Text <span class="changeme">The text we need to change</span></a>
.parent:hover .changeme:not(:hover) { background: #DDD; }
.parent:hover .changeme { background: #DDD; } .parent:hover .changeme:hover { background: transparent; }
You can not do that with CSS - you need JAVASCRIPT
4.What will the code below do ?
<script> var programmingLanguages = ["PHP", "RUBY", "PEARL", "PYTHON"]; jQuery.each(programmingLanguages, function(i,v){ console.log(i, v); }); </script>
Write the array index and values to the server logs
Syntax Error
Output the array index and values to the browser console
5.Which of the following snippets can be used to display a string only to visitors that use an outdated version of Internet Explorer (Versions 1-8) ?
Option: <?php $isoldie = preg_match('/(?i)msie [1-8]/',$_SERVER['HTTP_USER_AGENT']); if($isIE) echo 'You are using an old IE version'; ?>
<?php $isoldie = preg_match('/(?i)msie [1-8]/',$_SERVER['HTTP_USER_AGENT']); if($isIE) echo 'You are using an old IE version'; ?>
Option: <!--[if lte IE 8]> You are using an old IE version <![endif]-->
<!--[if lte IE 8]> You are using an old IE version <![endif]-->
Option: <?php $isoldie = get_browser(null, true); if($isoldie["majorver"] <= 8 and strtolower($isoldie["browser"])=='msie') echo 'You are using an old IE version'; ?>
<?php $isoldie = get_browser(null, true); if($isoldie["majorver"] <= 8 and strtolower($isoldie["browser"])=='msie') echo 'You are using an old IE version'; ?>
6.Considering the script below, what is the value of the "pricelist" variable ?
<script type="text/javascript"> var cars = new Object; cars.brands = ["Mercedes", "Opel", "Rolls Royce"]; cars.price = [50000, 20000, 100000]; for(i in cars.brands) { cars.b_and_p = "The " + cars.brands[i] + " is $" + cars.price[i]; } var pricelist = cars.b_and_p; </script>
["The Mercedes is $50000", "The Opel is $20000", "The Rolls Royce is $100000"]
"The Rolls Royce is $100000"
7.What is the form below used for ?
<form method="POST" enctype="multipart/form-data"> <input type="file" name="image"> <input type="submit" name="submit" value="submit"> </form>
Uploading files using POST
Uploading and encrypting files
The form doesn't work because it doesn't have the action attribute
8.Which of the CSS rules below will make a div element stick to the bottom-right area of the page all the time ?
div { position: static; bottom: 0; right:0; }
div { position: fixed; bottom: 0; right:0; }
div { position: relative; bottom: 0; right:0; }
9.Which of the following are valid HTML or XHTML Doctype declarations ?
<!DOCTYPE html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
10.What does the <datalist> tag do ?
This tag doesn't exist
The <datalist> tag is used to create a list of pre-defined possible values for an <input> element, providing suggestions for the users as they type inside the input element
The <datalist> tag is used to create a list of pre-defined possible values for a series of radio buttons or checkboxes generating them automatically according with the elements listed in <datalist>
11.What method is used in HTML to display alternate content to a user that has scripts disabled in his browser ?
Alternate content is added inside a <noscript> tag.
Alternate content is displayed by wrapping the script code in html comments (<!-- //-->) and adding the alternate text after the comments
The browser does this automatically there's no need to do anything
12.Which of the following statements are correct when dealing with data-* attributes in HTML ?
Data attributes must contain at least one letter after the "data-" prefix and the attribute can not contain uppercase letters
If the data attribute is added to an <input> tag inside a form, it will be sent to the server when the form is submitted
The value of the data attribute can be any string
13.What is the computed width of a <div> element that has the following css properties ?
div { width:100px; height:100px; border:1px solid #000; padding:5px; box-sizing:border-box; }
110px
112px
100px
14.The 'border-radius' property value can be defined in ...
pixels (px)
percentages (%)
points (pt)
15.Considering the snippet below, what happens when you hover over the red div element ?
<style> div { width:50px; height:50px; background:red; transition:all 2s; -webkit-transition:all 2s; } div:hover { width:100px; height:100px; background:blue; } </style> <div></div>
The div element gradually changes width over a 2 seconds period until it reaches 100px
The div element gradually changes width and height and color over a 2 seconds period until it reaches 100px in width and height and it becomes blue
The div element gradually changes width and height over a 2 seconds period until it reaches 100px in width and height
16.What CSS rule is used to load non web safe fonts in a web page ?
@font-face
font-src
font-family
17.Which of the following values are valid for the CSS3 background-clip property ?
border-box
content-box
none
18.What is the initial keyword used for in CSS ?
Resets the respective property to the last inherited value
Resets the respective property to the default value
Resets the respective property to the value that was first defined for it ignoring any subsequent overides
19.Assuming that "dir/dir/file.php" exists and that it returns "Success". What does the code below log to the console ?
<script> jQuery.ajax({ url: "dir/dir/file.php", type: "POST", data: "x=value", }).done( function (r) { console.log(r); }); </script>
200 - The HTTP status code
"Success"
NULL
20.Considering the code below, what happens when the page loads ?
<style> .one { width: 100px; height: 100px; } </style> <div class="one"></div> <div class="one"></div> <div class="one"></div> <div class="one"></div> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> (function( $ ) { $.fn.colorize = function() { this.each( function(){ var color = '#'+Math.floor(Math.random()*16777215).toString(16); $(this).css({background: color}); return this; }); }; }( jQuery )); jQuery('.one').colorize(); </script>
The 4 div elements are colored with the same random color.
The 4 div elements are colored with different random colors
The 4 div elements are colored with dark purple
21.What happens when you click on the 'Go' button ?
<input type="checkbox" name="check"> <button>Go</button> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script> jQuery('button').click(function(){ jQuery('input[type="checkbox"]').prop('checked', function() { return !(jQuery(this).prop('checked')); }); }); </script>
Nothing happens. The syntax is wrong. It should be jQuery('selector').prop('checked', true); or jQuery('selector').prop('checked', false);
jQuery('selector').prop('checked', true); or jQuery('selector').prop('checked', false);
The checked property of the input will toggle from true to false with each click.
The checkbox will turn from unchecked to checked when the button is first clicked. Subsequent clicks will have no effect.
22.Considering this HTML: <div class="myclass"></div>, which of the selectors below are correct ?
<div class="myclass"></div>
jQuery('div[class=myclass]')
jQuery('.myclass')
jQuery('.myclass', document)
23.Having this HTML code: <div id="myid" style="margin:10px; padding:10px; border:1px solid black; height:10px; width:10px;"></div> , what is the value of jQuery('#myid').outerHeight(true) ?
<div id="myid" style="margin:10px; padding:10px; border:1px solid black; height:10px; width:10px;"></div>
jQuery('#myid').outerHeight(true)
50
32
52
24.Considering the code below, what will happen when the input element will lose focus ?
<p> <input type="text" value=""> </p> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script> jQuery('p').focusout(function(){ console.log('focusout'); }); jQuery('p').blur(function(){ console.log('blur'); }); </script>
"focusout" will be printed in the console
"blur" will be printed in the console
"focusout" and "blur" will be printed in the console
25.What is the best way (performance-wise) to append each element of an array(['banana', 'orange', 'apple']) to an existing list in an html document (jQuery('ul#mylist')) ?
['banana', 'orange', 'apple']
jQuery('ul#mylist')
Build a string containing the new elements by looping through the array and then append the string to the HTML list: var fruit = ['Kiwi', 'Avocado', 'Pear']; var toAppend = ''; jQuery.each(fruit, function(i, v){ toAppend += "<li>" + v + "</li>"; }); jQuery( "#mylist" ).append(toAppend);
var fruit = ['Kiwi', 'Avocado', 'Pear']; var toAppend = ''; jQuery.each(fruit, function(i, v){ toAppend += "<li>" + v + "</li>"; }); jQuery( "#mylist" ).append(toAppend);
Detach the list from the DOM. Then build a string with the new elements by looping through the array. Then append the string to the detached list and finally add it back in the DOM: var list = jQuery( "#mylist" ); var parent = list.parent(); var fruit = ['Banana', 'Orange', 'Apple']; var toAttach = ''; list.detach(); jQuery.each(fruit, function(i, v){ toAttach += "<li>" + v + "</li>"; }); list.append(toAttach); parent.append(list);
var list = jQuery( "#mylist" ); var parent = list.parent(); var fruit = ['Banana', 'Orange', 'Apple']; var toAttach = ''; list.detach(); jQuery.each(fruit, function(i, v){ toAttach += "<li>" + v + "</li>"; }); list.append(toAttach); parent.append(list);
Just loop through each element of the array and append it to the list: var fruit = ['Lime', 'Mango', 'Pineapple']; jQuery.each(fruit, function(i, v){ jQuery( "#mylist" ).append("<li>" + v + "</li>"); });
var fruit = ['Lime', 'Mango', 'Pineapple']; jQuery.each(fruit, function(i, v){ jQuery( "#mylist" ).append("<li>" + v + "</li>"); });
26.Which selector is faster ?
jQuery(':checkbox')
jQuery('input:checkbox')
jQuery('*:checkbox')
27.Which animation is smoother ?
Animating the height of an element by adding/removing a CSS class that modifies the height and taking advantage of CSS3 'transitions'
Animating the height of the element using the slideUp/Down functions in jQuery
Both CSS based animations and the jQuery approach are just as smooth in any browser
28.How can jQuery access the 'name' property inside the object defined as the value of 'data-option' in the html tag below: <div data-options='{"name":"John", "age":"40"}'></div> ?
<div data-options='{"name":"John", "age":"40"}'></div>
var name = jQuery('div').data('options').name;
var name2 = jQuery.parseJSON(jQuery('div').attr('data-options')).name;
There's no way of doing that. The 'data-options' attribute has an invalid value