Sign in to queue

Description

This lesson shows how to utilize jQuery Events to create a simple game by writing and attaching anonymous functions to events fired on a web page.

Tag:

JavaScript

Embed

Download

The Discussion

  • User profile image
    asok14215

    There's some subtlety as to why the score variable can retain its value between clicks. I understand it because of my experience with C#, lambda expressions, and closures, but it might not be so obvious to the beginning programmer.

  • User profile image
    Ali

    Hi Bob , I really appreciate this series . it is so helpful and enlightening .

    I have two questions :
    if I have a loop ($.each) and inside I have a nested "if" statement when I am using the "return" keyword in the if statement it returns to the containing "each" statement instead of exit the function. what am I doing wrong ? ie:
    $('#btn').click(function () {
    var found = false;
    $.each(star1, function (i, val) {
    if (val == $('#starName').val()) {
    found = true;
    return ('found!!!'); // although that it is found the loop keep on going
    } else {
    if (i == (star1.length - 1)) {
    if (!found) {
    return ('not found');
    }//not found
    };
    };//end else
    });//end each

    });//end click

  • User profile image
    plok18644

    thank you bob tabor

  • User profile image
    guih6777

    I have never seen www.LearnVisualStudio.net

  • User profile image
    Jacob

    Hi Bob, is there a JQuery shortcut for every single Javascript command?

  • User profile image
    Jacob

    Also, I'm a little confused regarding the src script with the following anchor tag: http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.1.js

    Are we supposed to download jQuery, or can we just link all of our html files to that address?

    Thanks in advance.

  • User profile image
    BobTabor

    @Ali: When you put () around the value you're returning, you confuse javascript ... you're saying you want to call a method called return instead of the keyword.  Remove the () around ('found!!!') and I'm betting it will work.  Good luck!

    @Bob tabor is a idoit: . . . classy.  And grammatically challenged.

    @plok18644: You're welcome!

    @guih6777: How did you miss it!?  Wink

    @lib115634: Sorry?

    @Jacob: re: shortcuts ... I don't think so.  Just for the ones that are laborious to write.

    @Jacob: re: download ... You only reference THAT SINGLE FILE, the actual jQuery library file -->  jquery-1.7.1.js ... it is located at a number of web sites where it can be quickly downloaded (or perhaps even cached, if other web site builders like yourself use the same exact URL to host the file).  The remainder of your HTML , CSS and image files will point to YOUR domain name.  Hope that helps!

     

  • User profile image
    rohit

    hi bob,
    I feel like a devloper.

    Thanks.

  • User profile image
    TinTin

    So if I want to reset the score when I click Start Over, how would the code look like(what do U have to modify)?

  • User profile image
    BobTabor

    @TinTin: Hi TinTin ... I'm am absolutely NOT trying to be a smart aleck in what I'm about to say ... I believe in the "teach a man to fish and he'll fish for himself the rest of his life" philosophy.  So, tell me what you've tried already and let me walk you through it if you get stuck.  Hopefully if you've been following along up to this point, you should be able to do exactly what you're asking. 

    If you don't struggle, you don't truly learn.

  • User profile image
    TinTin

    Hello Bob,

    Thank you for the reply, I figured it out, had a bug in my code. The text would reset when I clicked start over, but it would display the score being 0 only after I hovered it one more time :))

    It is fixed now.

    Thanks for the series!

  • User profile image
    TinTin

    Hello Bob,

    Thank you for the reply, I figured it out, had a bug in my code. The text would reset when I clicked start over, but it would display the score being 0 only after I hovered it one more time :))

    It is fixed now.

    Thanks for the series!

  • User profile image
    Gowri

    need videos related to proxy in javascript

  • User profile image
    Mohamed

    Thank you Bob Tabor

Add Your 2 Cents