Thursday, July 30, 2015

JQuery Test Questions For Elance



What method is used to switch between adding/removing one or more classes (for CSS) from selected elements?
  • toggleClass()
  • switch()
  • switchClass()
  • classSwitch()
Answer: toggleClass()
What keyword would you use to refer to the object on which the currently executing method has been invoked?
  • that
  • object
  • this
  • here
  • medium
Answer: this
Which sign does jQuery use as a shortcut for jQuery?
  • the $ sign
  • the . sign
  • the > sign
  • the # sign
Answer: the $ sign





What does the empty() function do?
  • Clears the text in a node
  • Removes all child nodes of the set of matched elements from the DOM including the parent node
  • Checks if a node is empty
  • Removes all child nodes of the set of matched elements from the DOM
Answer: Removes all child nodes of the set of matched elements from the DOM
<div id="MyDiv">Two</div> <div id="MyDiv">One</div> <div id="MyDiv">Five</div> Given the above HTML What would the output of the following code be? var myDivText = $('#MyDiv').text() console.log(myDivText)
  • Undefined
  • Null
  • Two
  • One
  • Five
Answer: Two

Which function does jQuery provide to remove whitespace from the beginning and end of a string?
  • $.stripspace( )
  • $.trim( )
  • $.strip( )
  • jQuery does not provide such function.
Answer: $.trim( )



What is the output of the following: $.each([1,2,3], function(){ document.write(this + 1); });
  • 223
  • 1231
  • "234"
  • undefined
Answer: "234"
What is true of the following code? $('<img>', { src: 'images/little.bear.png', alt: 'Little Bear', title:'I woof in your general direction', click: function(){ alert($(this).attr('title')); } })
  • It will alert "title"
  • It will alert the name of the element being clicked
  • It will alert the value of title attribute of the image being clicked
  • It will alert attribute title
Answer: It will alert the value of title attribute of the image being clicked
For best performance in modern browsers, which of the following would you use to select all radio inputs?
  • $('[type="radio"]');
  • $('[input.radio]');
  • $('[input="radio"]');-21pts
  • $('||radio');
  • $('.radio');
Answer: $('[type="radio"]');




When an event is triggered on an element, the same event is also triggered on all of that element’s ancestors. What is the name of this process?
  • medium
  • event bubbling
  • upward progress
  • progressive enhancement-23pts
  • global event
Answer: event bubbling
What method checks for the presence of a class before applying or removing it?
  • .apply_remove()
  • medium
  • .checkPresence()
  • .checkFunction()
  • .toggleClass()
Answer: .toggleClass()
Which selector will only return one element?
  • :nth-child()+40pts
  • :one-based()
  • :even
  • :odd
Answer: nth-child()





What is the equivalent of the following code? $('div').click(function {alert(1);});
  • $('div').call('click',function {alert(1);});
  • $('div').bind('click',function {alert(1);});
  • $('div').handler('click',function {alert(1);});
  • $('div').event('click',function {alert(1);});
Answer: $('div').bind('click',function {alert(1);});
What term refers to the acceleration and deceleration that occurs during an animation?
  • gradient
  • speeding
  • velocity
  • resizing
  • easing
Answer: easing
What does the following code do? $(".foobar").find(".foo").fadeOut();
  • Fade out of all descendants of elements matching ".foo" inside those matching ".foobar"-30pts
  • Fade out of elements matching ".foobar"
  • Fade out of elements matching ".foo" that are descendants of elements matching ".foobar"
  • Fade out of all children of elements matching ".foobar"
Answer: Fade out of elements matching ".foo" that are descendants of elements matching ".foobar"




Which custom selector is case sensitive?
  • :contains()
  • :includes()
  • medium
  • :case()
  • :custom()
Answer: :contains()
True or False? jQuery UI is part of jQuery.
  • True
  • False
Answer: False
<p>Hello</p> $('p').prepend('world '); $('p').append('.'); p = ?
  • world Hello.
  • Helloworld .
  • .world Hello
Answer: world Hello.
$.foo() is equivalent to:
  • javascript.foo()
  • document.foo()
  • None of them
  • jQuery.foo()
Answer: jQuery.foo()







What is '$();' equivalent to?
  • operator();
  • java();
  • Function();
  • function();
  • jQuery();
Answer: jQuery();
Which is a class selector?
  • $('.name')
  • $('#name')
  • $('_name')
Answer: $('.name')
What language is jQuery written in?
  • CSS
  • Java
  • JavaScript
  • PHP
Answer: JavaScript
What does this script do? $(function() { $( "#effect" ).animate({ backgroundColor: "#fff" }, 1000 ); });
  • Changes the background color of the element with id 'effect' to #fff within 1 second.
  • Changes the background color of the element with class 'effect' to #fff within 1 second.
Answer: Changes the background color of the element with id 'effect' to #fff within 1 second.



Which of the following is correct?
  • jQuery is a JSON Library
  • None of these
  • jQuery is a JavaScript Library
Answer: jQuery is a JavaScript Library
Illustrate the code needed to include the jQuery library in an HTML file:
  • $(script) src="jQuery.js")
  • $(script src)="jQuery.js"(/script)
  • <script src="jQuery.js"></script>
  • $script src="jQuery.js"
Answer: <script src="jQuery.js"></script>
What do selectors do?
  • Allows the content to be stopped at some point.
  • Allows you to select HTML elements (or groups of elements) by element name, attribute name or by content.+6pts
  • Allows selection of libraries.
  • Allows you to select an array in the node list.
Answer: Allows you to select HTML elements (or groups of elements) by element name, attribute name or by content.

Which is NOT a jQuery method?
  • show()
  • fadeIn()
  • toggle()
  • alias()
Answer: alias()



In the following statement, which is the selector? $('p').css('color','blue');
  • .css
  • p
  • blue
  • color
Answer: p
Which of the following is used to schedule a function to execute after an animation has completed?
  • AJAX
  • graceful degradation
  • progressive enhancement
  • callback function
  • chaining
Answer: callback function
What does the following return? $.inArray("foo", ["foo", "bar"]);
  • true
  • 0
  • TRUE
  • 1
Answer: 0
How would you prevent the default browser action from an event handler without affecting other properties of the event flow?
  • $a.click(function () { /* code */ return false; });
  • $a.click(false);
  • $a.click(function (e) { /* code */ e.returnValue = false; });
  • $a.click(function (e) { /* code */ e.preventDefault(); });
Answer: $a.click(function (e) { /* code */ e.preventDefault(); });

Which method is used to bind an event handler to existing and future matching elements?
  • attach();
  • click();
  • .on();
Answer: .on();
You can copy an element by calling which of the following methods?
  • cloneTo()
  • copy()
  • moveTo()
  • clone()
Answer: clone()
What is the proper way to show an element?
  • $('#foo').style('show');
  • $('#foo').show();
  • $('#foo').display('show');
  • $('#foo').showElement();
Answer:$('#foo').show();
Which of these is NOT a valid way to initiate the document.ready call?
  • jQuery(document).ready(function($) { /* Stuff here */ })(jQuery);
  • $(document).ready(function() { /* Stuff here */ });
  • $(function() { /* Stuff here */ });
  • (function(x) { x(function() { /* Stuff here */ }); })(jQuery);
Answer: jQuery(document).ready(function($) { /* Stuff here */ })(jQuery);





What language is jQuery constructed in?
  • C++
  • Java
  • PHP
  • JavaScript
Answer: JavaScript
You can animate 'color' and 'background-color' properties.
  • False
  • True
Answer: False

How is jQuery licensed?
  • Proprietary
  • Open source
  • Secret
  • Private
Answer: Open source
What is $(fn); a shortcut for?
  • $(window).on('load', fn);
  • $( fn() ); // Shortcut to create or select elements using the string returned by the "fn" function.
  • $(document).ready(fn);
Answer: $(document).ready(fn);





Which of the following syntaxes are equivalent to $(document).ready(handler)?
  • .ready()
  • All of these
  • .load()
  • $(handler)
Answer: $(handler)
How do I pull a native DOM element from a jQuery object?
  • $("#foo[0]");
  • $( "#foo" ).get( 0 );
  • $( "#foo" ).get(native[ 0 ]);
  • $( "#foo" ).find(native[ 0 ]);
Answer: $( "#foo" ).get( 0 );
What does the following code do: $('#myDiv').trigger('click');
  • When a click occurs the trigger is going to be activated.
  • It makes a click on any element and creates a trigger.
  • It sets up a trigger. When a click occurs, the trigger is going to be activated.
  • It simulates a click on the element and runs all the event handlers associated with it.
Answer: It simulates a click on the element and runs all the event handlers associated with it.

What does $('#myDiv').load('page.html') do?
  • it loads the #myDiv on the contents of the 'page.html' browser
  • it fires an AJAX request, fetches the result of page.html as text, and inserts it into the div
  • It adds the string 'page.html' as the contents of the #myDiv div.
Answer: it fires an AJAX request, fetches the result of page.html as text, and inserts it into the div
The selector :disabled will perform the following:
  • None of the above
  • Select only elements in a disabled state
  • Disable any elements currently set to an enabled state
  • Create a new element with the state set to disabled
Answer: Select only elements in a disabled state
What does the $.get() jQuery function do?
  • It fires a GET OBJECT request
  • It fires a GET AJAX request
  • It returns the DOM elements that are contained in the jQuery object.
  • It returns an object
Answer: It fires a GET AJAX request
How do you clear the contents of this paragraph element? <div id='file'><p>content goes here</p></div>
  • $("file").clear();
  • $("#p").empty()
  • $('#file p').empty();
  • $(".file").empty();
  • $("#file").clear();
Answer: $('#file p').empty();

Which jQuery function is used to prevent code from running, before the document is finished loading?
  • $(document).ready()
  • $(body).onload()
  • $(window).load()
  • $(document).load()
Answer: $(document).ready()

Which method stops an event before the default action is triggered?
  • .preventDefault()
  • medium
  • .end()
  • .stopEvent()
  • .stopDefault()
Answer: .preventDefault()
Which of the following statement best described the following code snippet: $('#myID').animate({width:"90%"}, "fast");
  • Animate the tag with myID from 90% width to 100% width.
  • Animate the tag with myID from 90% width to 0% width.
  • Animate the tag with myID from 90% width to the current width.
  • Animate the tag with myID from the current width to 90% width.
Answer: Animate the tag with myID from the current width to 90% width.

No comments:

Post a Comment