12.07.2015 Views

Pro JavaScript for Web Apps pdf - EBook Free Download

Pro JavaScript for Web Apps pdf - EBook Free Download

Pro JavaScript for Web Apps pdf - EBook Free Download

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 2 GETTING STARTED($0)Total:$0I have highlighted the additional elements in the listing. They are all assigned to the latent class,which has the following definition in the styles.css file:....latent {display: none;}...I showed you earlier in the chapter that the jQuery hide method sets the CSS display property tonone to hide elements from the user, and I have followed the same approach when setting up this class.The elements are in the document but not visible to the user.Showing the Latent ContentNow that the latent elements are in place, I can work with them using jQuery. The first step is to revealthem to the user. Since I am manipulating the elements using <strong>JavaScript</strong>, they will be revealed only tousers who have <strong>JavaScript</strong> enabled. Listing 2-13 shows the addition to the script element.Listing 2-13. Revealing the Latent Content...$(document).ready(function() {$('#buttonDiv input:submit').hide();$('Submit Order').appendTo("#buttonDiv").addClass("button").click(function(e) {$('<strong>for</strong>m').submit();e.preventDefault();}).hover(function(e){var elem = $('#buttonDiv a')if (e.type == "mouseenter") {elem.addClass("buttonHover");31www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!