kzen.dev
  • Küsimused
  • Sildid
  • Kasutajad
Teated
Preemiad
Registreerimine
Kui olete registreerunud, teavitatakse teid vastustest ja kommentaaridest teie küsimustele.
Logi sisse
Kui teil on juba konto, logige sisse, et kontrollida uusi teateid.
Lisatavate küsimuste, vastuste ja kommentaaride eest antakse auhindu.
Rohkem
Allikas
Muuda
Sergio  del Amo
Sergio del Amo
Küsimus

Kuidas tuvastada klõpsu väljaspool elementi?

Mul on mõned HTML-menüüd, mida ma näitan täielikult, kui kasutaja klõpsab nende menüüde päises. Tahaksin neid elemente peita, kui kasutaja klõpsab väljaspool menüüd' ala.

Kas midagi sellist on võimalik jQuery abil?

$("#menuscontainer").clickOutsideThisElement(function() {
    // Hide the menus
});
2356 2008-09-30T13:17:12+00:00 3
Peter Mortensen
Peter Mortensen
Redigeeritud küsimus T66 oktoober 2016 в 4:05
Programmeerimine
javascript
jquery
Populaarsed videod
The Great Gildersleeve: Jolly Boys Election / Marjorie's Shower / Gildy's Blade
The Great Gildersleeve: Jolly Boys Election / Marjorie's Shower / Gildy's Blade
10 aastat tagasi
Dragnet: Big Cab / Big Slip / Big Try / Big Little Mother
Dragnet: Big Cab / Big Slip / Big Try / Big Little Mother
10 aastat tagasi
Calling All Cars: Ice House Murder / John Doe Number 71 / The Turk Burglars
Calling All Cars: Ice House Murder / John Doe Number 71 / The Turk Burglars
10 aastat tagasi
The great porn experiment | Gary Wilson | TEDxGlasgow
The great porn experiment | Gary Wilson | TEDxGlasgow
11 aastat tagasi
The Long Way Home / Heaven Is in the Sky / I Have Three Heads / Epitaph's Spoon River Anthology
The Long Way Home / Heaven Is in the Sky / I Have Three Heads / Epitaph's Spoon River Anthology
10 aastat tagasi
Suspense: Mister Markham, Antique Dealer / The ABC Murders / Sorry, Wrong Number - East Coast
Suspense: Mister Markham, Antique Dealer / The ABC Murders / Sorry, Wrong Number - East Coast
10 aastat tagasi
The Great Gildersleeve: The First Cold Snap / Appointed Water Commissioner / First Day on the Job
The Great Gildersleeve: The First Cold Snap / Appointed Water Commissioner / First Day on the Job
11 aastat tagasi
The Case of the White Kitten / Portrait of London / Star Boy
The Case of the White Kitten / Portrait of London / Star Boy
10 aastat tagasi
Subways Are for Sleeping / Only Johnny Knows / Colloquy 2: A Dissertation on Love
Subways Are for Sleeping / Only Johnny Knows / Colloquy 2: A Dissertation on Love
10 aastat tagasi
Suspense: Blue Eyes / You'll Never See Me Again / Hunting Trip
Suspense: Blue Eyes / You'll Never See Me Again / Hunting Trip
10 aastat tagasi
The Enormous Radio / Lovers, Villains and Fools / The Little Prince
The Enormous Radio / Lovers, Villains and Fools / The Little Prince
10 aastat tagasi
Sin Piedad: Spaguetti-Western documental completo (Without Mercy)
Sin Piedad: Spaguetti-Western documental completo (Without Mercy)
10 aastat tagasi
Suspense: Heart's Desire / A Guy Gets Lonely / Pearls Are a Nuisance
Suspense: Heart's Desire / A Guy Gets Lonely / Pearls Are a Nuisance
10 aastat tagasi
The Ex-Urbanites / Speaking of Cinderella: If the Shoe Fits / Jacob's Hands
The Ex-Urbanites / Speaking of Cinderella: If the Shoe Fits / Jacob's Hands
10 aastat tagasi
« Eelmine
Järgmine »
See küsimus on 1 vastus inglise keeles, nende lugemiseks logi sisse oma kontole.
Lahendus / vastus
Eran Galperin
Eran Galperin
T11 september 2008 в 1:38
2008-09-30T13:38:11+00:00
Rohkem
Allikas
Muuda
#8524485

MÄRKUS: stopEventPropagation() kasutamist tuleks vältida, kuna see katkestab normaalse sündmuste liikumise DOMis. Lisateavet vt see artikkel. Kaaluge selle asemel selle meetodi kasutamist.

Kinnitage dokumendi kehale klõpsu sündmus, mis sulgeb akna. Kinnitage konteinerile eraldi klõpsusündmus, mis peatab leviku dokumendikorpusesse.

$(window).click(function() {
//Hide the menus if visible
});

$('#menucontainer').click(function(event){
    event.stopPropagation();
});
Renz Dominique
Renz Dominique
Redigeeritud vastus T22 detsember 2018 в 7:43
The Dangers of Stopping Event Propagation | CSS-Tricks - CSS-Tricks
The following is a guest post by Philip Walton (@philwalton). He is going to explain why stopping event propagation isn't something you should do lightly, and
css-tricks.com
1757
0
Artificial intelligence to parse product page
productapi.dev
Joe Lencioni
Joe Lencioni
T11 september 2008 в 6:13
2008-09-30T18:13:39+00:00
Rohkem
Allikas
Muuda
#8524488

Mul on rakendus, mis töötab sarnaselt Eran's näide, kuid ma kinnitan klõpsu sündmuse keha, kui ma avan menüü... Umbes nii:

$('#menucontainer').click(function(event) {
  $('html').one('click',function() {
    // Hide the menus
  });

  event.stopPropagation();
});

Lisateave jQuery's one() funktsiooni kohta

 Lal
Lal
Redigeeritud vastus T44 veebruar 2016 в 2:57
.one() | jQuery API Documentation
docs.jquery.com
126
0
Artificial intelligence to parse product page
productapi.dev
Chris MacDonald
Chris MacDonald
T11 september 2008 в 1:20
2008-09-30T13:20:30+00:00
Rohkem
Allikas
Muuda
#8524484

Kontrollige akna klõpsu sündmuse sihtmärki (see peaks levima aknale, kui see ei ole kuskil mujal jäädvustatud) ja veenduge, et see ei ole mõni menüüelement. Kui see ei ole, siis olete väljaspool oma menüüd.

Või kontrollige klõpsu asukohta ja vaadake, kas see's sisaldub menüüpiirkonnas.

20
0
Lisa küsimus
Kategooriad
Kõik
Tehnoloogia
Kultuur / Vaba aeg
Elu / Kunst
Teadus
Professionaalne
Äri
Kasutajad
Kõik
Uus
Populaarne
1
Inessa bu
Registreeritud 1 kuu tagasi
2
Denis Babushkin
Registreeritud 1 kuu tagasi
3
asakuno asakuno
Registreeritud 1 kuu tagasi
4
aldo salerno
Registreeritud 1 kuu tagasi
5
Анна Батицкая
Registreeritud 2 kuud tagasi
Artificial intelligence to parse product page
productapi.dev
BG
DE
EL
ES
ET
FR
ID
IT
JA
LT
LV
NL
NO
PT
RO
SK
SL
TR
ZH
© kzen.dev 2023
Allikas
stackoverflow.com
litsentsi alusel cc by-sa 3.0 atribuudiga