Javascript final

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

how is a jquery selector formed?

$(" ") no dot operator!!

Given: var myhotel = new Object(); myhotel.name = 'Quay'; myhotel.rooms = {studio: 40, suite: 25 } ; myhotel.booked = {studio: 25, suite: 20 } ; myhotel.checkAvailability = function(type) { return this.rooms[type] - this.booked[type]; }; var room = myhotel.checkAvailability ('suite'); What will be the value of variable room after the above js code executed>

5

Assuming an object course is created, which of the following change the value of the name property of that object to CS381 ? course.name() = 'CS381'; course.name = CS381; course['name'] =' CS381'; course[name] =' CS381';

course['name'] =' CS381';

what jquery method would you used to execute a method for each element in an array?

each()

Event delegation allows us to attach a single event handler to all descendant elements, that will fire for a parent element,whether those descendants exist now or are added in the future.

false

what does the following jquery code do? $("h2").prev()

gets the previous sibling of the selected h2 element

$("#itemlist").on('click","button", function(){....}; explain??

handles the click event of the button elements within a parent element with an id of "item list" if the button elements are added to the web page by using javascript after the web page is loaded

how do you tell if a radio button has been selected?

if .checked=true;

if you download the jquery core library, can you include it in a web page by coding a <link> element

no

After you've defined a constructor function for creating multiple objects, you can add a method by adding a function to its________________ so that all object instances created by using that constructor function will have access to that method. method property prototype object Function object Object object

prototype object

How can you clear a check from a Checkbox object (i.e., <input type="checkbox"> element in html)?

set its checked property to false

which proper of the event object would tell you which element an event happened upon?

target

When a function without parameters is called as an event handler, this keyword in that function refers to: the event the argument array in the event handler the element that the event fires on the first argument in the event handler

the element that the event fires on

The difference between the prepend and before methods is that hint: one inserts in the elements one inserts outside the element

the prepend method inserts content within an element, and the before method inserts it outside the element

Given, btn.onclick = function () { alert(this.id); }; //add event handler If we want to remove that event handler, we can write: btn.onclick = null;

true

T/F? a function for the jquery ready method will run any methods that it contain as soon as the DOM is ready

true

To delete a property or a method from an object, we can use delete keyword.

true

To detach an event handler to an event with jQuery, you can use the off() method.

true

toLowerCase() is a method of String object, to convert a string to all lower case characters.

true

Which property of the event object tells the type(or say the name) of the event occurs?

type

Given, var hotel = { name: 'Quay', rooms: 40, booked: 25, roomTypes: ['studio', 'family', 'suite' ] }; How many properties and methods in hotel object?

There are four properties and no method in the object.

what is an event handler?

A function that is called with a certain event occurs. Examples of these include button.onclick and window.onload.

what is an event object?

All event objects in the DOM are based on the Event Object. Therefore, all other event objects (like MouseEvent and KeyboardEvent) has access to the Event Object's properties and methods.

What is an event?

An HTML event can be something the browser does, or something a user does.

Which event occurs when an element on the page loses focus?

Blur

For the following code, an event handler function named investment_change will be executed when the load event occurs. window.onload = function() { $("investment").onclick = investment_change; }

False

eventPhase property of event object will return a number (e.g., 1, 2, and 3) indicates event flow phases. If this property returns 1, indicates bubbling phase. If it returns 2, indicates target phase. If it returns 3 indicating capture phase.

False, it actually goes capture target bubbling.

is jquery a java library

No! it is a javascript library! make sure to read careful

$("image").attr("src", imageURL) explain??

SETS the value of the SRC attribute for he element with an ID of "image"to the value in a VARIABLE named imageurl

Which of the following is a true statement about objects in JavaScript: The String type inherits the methods of the Array type The Object type inherits the methods of the Function type The Number type inherits the methods of the Object type. The Object type inherits the methods of the String type.

The Number type inherits the methods of the Object type.

An event handler is the js code that is run when an event occurs.

True

Given, var person = {firstName: 'John', lastName: 'Doe', age: 50, eyeColor: 'blue'}; var personInfo = Object.keys(person); The value of variable personInfo after the above JS code executed is an array that contains all property names.

True

In the code that follows, onload is a property that represents "load" event. window.onload = function() { alert("This is a new page!"); };

True

The target property of event object references the DOM element that triggers event. The currentTarget property of event object references the DOM element that event handler registered to.

True

When a function passes a value back to the calling statement, it uses a return statement.

True

The add function in the following example: var add = function( x, y ) { return ( x + y ); } alert( add (5, 3) ); accepts ___ parameters and returns ____ value

accepts 2 parameters and returns 1 value.

to add a new element after a paragraph element, which jquery method would you use?

after()

The three event flow phase in event propagation are:

capture, target, and bubbling.

how do you attach an event handler to an event with jquery?

use the on() method

what jQuery method is used to get the val of an input text box?

val()


Ensembles d'études connexes

REGISTRY REVIEW IN COMPUTED TOMOGRAPHY TEST 4

View Set

Conceptual Physics Midterm 2016 (1-9)

View Set

Chapter Two: East and West Perspectives

View Set

Mood, Adjustment, and Dementia Disorders PrepU

View Set

GEOG 1125 Ch 8.3: Raising Livestock

View Set

Tema 1. Carta certificada tradicional

View Set