Another way to write this?

Discussion in 'Javascript' started by laredotornado, Sep 6, 2011.

  1. Hi,

    I have this JS ...

    if(img.alt == 'Yes');

    Is there anotehr way to write the "" clause that doesn't
    use the "click()" action but achieves the same thing? Thanks, - Dave
    laredotornado, Sep 6, 2011
    1. Advertisements

  2. What might be the idea behind that?

    You seem to ask how to eat your cake without eating your cake.

    On the other hand, by default, clicking on an image has no effect, so
    there is no "same thing" to be achieved. And if you have assigned an
    onclick handler to an image, then you could just call that handler
    instead of using the event.

    What's the real problem you're trying to solve?
    Jukka K. Korpela, Sep 6, 2011
    1. Advertisements

  3. laredotornado

    dhtml Guest

    Clicking on the IMG has the effect of calling any registered handlers
    on that element.

    Calling a "click" method on the IMG, where supported, will cause an
    event to be fired at that object and unless propagation is stopped, it
    will bubble.

    That's going to add complexity with the `event` parameter (or
    `window.event`). I'd avoid doing that.
    That's the right question right there. Describe the goal, not the
    dhtml, Sep 8, 2011
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.