(^484) ❘ APPENDIX A EXERCISE ANSWERS
bapp01.indd 02/18/2015 Page 484
- Naming an instance of an event handler can be done by applying the event name, a dot, and
then the namespace you want to use. You can apply multiple event names by repeating the
same process. - The off() method.
- Yes.
- You can use either click() with no arguments or trigger('click').
- A custom event handler begins with any event name not already in use in JavaScript; you can
attach a custom event handler using that name using the on() method. The trigger() method
can be used to fi re the custom event handler, as well as to send custom data to the event
handler.
CHAPTER 4
- One possibility:
$('input').attr(
'value' : 'Some Value'.
'class' : 'someClass'
);Another possibility:
$('input').addClass('someClass').val('Some Value');- It might look like this:
$('a').attr('href', 'http://www.example.com');- removeAttr()
- hasClass()
- No, HTML tags will not be present in the return value, only the element’s text content.
- Yes, HTML tags will be escaped and treated like text content.
- One bug that jQuery’s append() and prepend() methods work around in IE is how IE makes
innerHTML Read Only onelements.
- One bug that jQuery’s append() and prepend() methods work around in Firefox is how
Firefox occasionally loses form input values when appending or prepending HTML content
using innerHTML.
- insertBefore()
- wrapAll()
- outerHTML
- One bug that jQuery’s append() and prepend() methods work around in Firefox is how