From:  Dan Scott <dan@coffeecode.net>
Date:  08 May 2017 21:29:54 Hong Kong Time
Newsgroup:  news.mozilla.org/mozilla.dev.mdc
Subject:  

Re: Why this jQuery not working?

NNTP-Posting-Host:  63.245.214.181

Ah, fired up the Firefox Dev Tools and debugged what's happening.

When you click the button, the click handler is firing for both the button
and the body element. First the click handler you registered on the button
fires ("hide button"); then the click handler on the body fires ("show
button"), effectively resulting in no change. jQuery seems to propagate the
event up to body and to have it run last, whereas if you wrap the button in
a div and register a click handler on the div, a click on the button
doesn't propagate to the div. Weird.

I would suggest creating a sibling element to the button, such as "
Or click me
" and register that as the click handler to show the button. Also I'm not sure if this mailing list is the right forum for these kinds of questions; is this related to a specific section of an MDN tutorial? On Mon, May 8, 2017 at 8:59 AM, M A wrote: > Not working.. Tried both... Giving both button hide and button show > together does not hide also... > > On May 8, 2017 8:46 PM, "Dan Scott" wrote: > >> Could be that body, with nothing to show, collapses to an effective >> height of 0 pixels. Try adding another element to the body so that it has >> an implicit height and there will be some obvious target within it to click >> on, or style the body so it has an explicit height dimension. >> >> On Mon, May 8, 2017, 08:27 M A wrote: >> >>> Still not working >>> >>> On May 8, 2017 20:17, "Dan Scott" wrote: >>> >>>> Try changing body.show to button.show. The body element is already >>>> displayed, it's the button that has been hidden. >>>> >>>> On Mon, May 8, 2017, 08:12 M A wrote: >>>> >>>>> >>>>> >>>>> >>>>> Jquery Test >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> It only hides when clicked but does not show when body clickedd! >>>>> ____________________________________________________________ >>>>> _____________ >>>>> Discussing Developer documentation on MDN: dev-mdc mailing list >>>>> List email: dev-mdc@lists.mozilla.org >>>>> Manage your membership: https://lists.mozilla.org/listinfo/dev-mdc >>>>> Unsubscribe: https://lists.mozilla.org/opti >>>>> ons/dev-mdc/dan%40coffeecode.net?unsub=1&unsubconfirm=1 >>>>> MDN contributor guide: http://bit.ly/ContributorGuide >>>>> >>>>