Show, Hide and Toggle

11 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€94.09
List Price:  €131.73
You save:  €37.64
£80.33
List Price:  £112.47
You save:  £32.13
CA$137.95
List Price:  CA$193.14
You save:  CA$55.18
A$155.90
List Price:  A$218.27
You save:  A$62.36
S$136.45
List Price:  S$191.03
You save:  S$54.58
HK$783.08
List Price:  HK$1,096.34
You save:  HK$313.26
CHF 91.31
List Price:  CHF 127.84
You save:  CHF 36.52
NOK kr1,099.13
List Price:  NOK kr1,538.83
You save:  NOK kr439.69
DKK kr702.04
List Price:  DKK kr982.89
You save:  DKK kr280.84
NZ$169.94
List Price:  NZ$237.92
You save:  NZ$67.98
د.إ367.20
List Price:  د.إ514.10
You save:  د.إ146.89
৳10,968.60
List Price:  ৳15,356.49
You save:  ৳4,387.88
₹8,361.11
List Price:  ₹11,705.89
You save:  ₹3,344.78
RM479.15
List Price:  RM670.83
You save:  RM191.68
₦120,104.65
List Price:  ₦168,151.32
You save:  ₦48,046.66
₨27,798.84
List Price:  ₨38,919.49
You save:  ₨11,120.65
฿3,667.03
List Price:  ฿5,133.99
You save:  ฿1,466.96
₺3,248.77
List Price:  ₺4,548.41
You save:  ₺1,299.64
B$518.45
List Price:  B$725.86
You save:  B$207.40
R1,905.92
List Price:  R2,668.37
You save:  R762.44
Лв184.07
List Price:  Лв257.70
You save:  Лв73.63
₩139,257.60
List Price:  ₩194,966.22
You save:  ₩55,708.61
₪377.23
List Price:  ₪528.13
You save:  ₪150.90
₱5,695.28
List Price:  ₱7,973.62
You save:  ₱2,278.34
¥15,458.12
List Price:  ¥21,641.98
You save:  ¥6,183.86
MX$1,680.99
List Price:  MX$2,353.45
You save:  MX$672.46
QR365.97
List Price:  QR512.38
You save:  QR146.40
P1,384.25
List Price:  P1,938
You save:  P553.75
KSh13,148.68
List Price:  KSh18,408.68
You save:  KSh5,260
E£4,851.82
List Price:  E£6,792.74
You save:  E£1,940.92
ብር5,709.83
List Price:  ብር7,993.99
You save:  ብር2,284.16
Kz83,396.59
List Price:  Kz116,758.56
You save:  Kz33,361.97
CLP$97,269.27
List Price:  CLP$136,180.87
You save:  CLP$38,911.60
CN¥723.78
List Price:  CN¥1,013.33
You save:  CN¥289.54
RD$5,930.22
List Price:  RD$8,302.55
You save:  RD$2,372.32
DA13,484.73
List Price:  DA18,879.17
You save:  DA5,394.43
FJ$227.82
List Price:  FJ$318.96
You save:  FJ$91.14
Q778.21
List Price:  Q1,089.53
You save:  Q311.31
GY$20,908.09
List Price:  GY$29,272.17
You save:  GY$8,364.07
ISK kr14,179.58
List Price:  ISK kr19,851.98
You save:  ISK kr5,672.40
DH1,015.88
List Price:  DH1,422.27
You save:  DH406.39
L1,779.82
List Price:  L2,491.82
You save:  L712
ден5,791.90
List Price:  ден8,108.89
You save:  ден2,316.99
MOP$805.91
List Price:  MOP$1,128.31
You save:  MOP$322.39
N$1,902.84
List Price:  N$2,664.06
You save:  N$761.21
C$3,694.12
List Price:  C$5,171.92
You save:  C$1,477.79
रु13,341.25
List Price:  रु18,678.28
You save:  रु5,337.03
S/371.93
List Price:  S/520.72
You save:  S/148.78
K379.86
List Price:  K531.82
You save:  K151.96
SAR375.07
List Price:  SAR525.11
You save:  SAR150.04
ZK2,516.51
List Price:  ZK3,523.21
You save:  ZK1,006.70
L468.24
List Price:  L655.55
You save:  L187.31
Kč2,375.47
List Price:  Kč3,325.75
You save:  Kč950.28
Ft37,163.97
List Price:  Ft52,031.05
You save:  Ft14,867.07
SEK kr1,095.61
List Price:  SEK kr1,533.90
You save:  SEK kr438.29
ARS$86,820.40
List Price:  ARS$121,552.04
You save:  ARS$34,731.63
Bs693.54
List Price:  Bs970.99
You save:  Bs277.44
COP$387,000.37
List Price:  COP$541,816
You save:  COP$154,815.63
₡50,265.75
List Price:  ₡70,374.06
You save:  ₡20,108.31
L2,477.69
List Price:  L3,468.86
You save:  L991.17
₲740,341.68
List Price:  ₲1,036,507.98
You save:  ₲296,166.29
$U3,889.78
List Price:  $U5,445.86
You save:  $U1,556.07
zł407.99
List Price:  zł571.20
You save:  zł163.21
Already have an account? Log In

Transcript

Hello in this jQuery video I am going to show you the holiday in and showing effect. So first of all let's create some element. Any element you want you can hide whatever you want anything that you can select you can hide and show it was created there and say hello world. Also tunics pizza I love pizza. Okay, so we're gonna do is created for Tim on click this button he will you know hide it also button button button button. So going to have an ID and this is going to be hide button and I'm also gonna have one call Showing as well separate one.

And you can use the code that we trigger from the Highland show in any capacity that you like. Show it. So we get these two buttons at the moment, they obviously do not do a JavaScript file, we need to actually detect for that button click. So, select is a hash foil button, dot click, and there's gonna be a function callback. And here is where you actually hide it. So you need to select that element.

So let's say um, select audience. You can use any complex or basic selected one dot find. So if I copy this, paste it Oh, push show I'm gonna show now if I reload it, click Show does nothing for your to the elements. So to see what the portlet call, as it sees disappears what's happened. It's though the content still there in the DOM. But the fact you just had a display of nonsense apply to so that way, it's just not visible anymore.

If I click Show, it shows it in another method that you can use for how you didn't show in is the toggle method. So depending on the current state to do the opposite of is hidden, you show it if it's, you know, visible, a toggle button. I'll say toggle and knife or duplicate this so when the toggle button is clicked, it's like so and for reload, click that he just toggle between it's a perfect show The code toggle will just know exactly what's happening with it and you show it or hide it accordingly. One other you know, as a two other things I want to show you in relation to how you can show it. You can also pass in an optional speed parameter. So what you can do is I'm going to create two more buttons acting on my rifle first just to stay here, okay two buttons, and then a few different ways that you can acquire speed.

So, you there is a built in low speed low this will be fast So if I just detect the click of the button, if I just do slow, like so fast as well. This optional speed parameter can actually be supplied for the hide the shell all the toggle, I'm going to just apply for the toggle to the to the on and off as you can see both ways with less code. And all you do is with quotation mark the keyword slow until the keyword before I really I click slow, I didn't see it actually shows it and makes it disappear but it's quite slow. If you want it faster, you can do faster if you actually want to customize it and provide an exact value of how long it's going to take tuna hide show or toggle it can provide that as well and that will in milliseconds, so what we'll do, we will quickly write operation input.

First, we don't have to have an input, you could directly just have a value in code, but we'll make it a bit dynamic. So I'm going to say ID. And the idea is going to be due for the time, and this is going to have a type of text. And now afterwards, I'm going to have a button. And this button is going to be similar to the ID. It's gonna have custom speeds on say custom, custom speed button.

So If I reload it, you haven't been programmed in yet. But what will happen when I click this, whatever valleys in here will be applied to this in terms of toggling on and off again, this can be applied to just directly to the slot, I mean directly to the hide and show method. I'm going to keep us informed like that. And I'll actually even have a default value as well. And the value will be zero. So basically instant So, okay, so now if we, first of all, we want to say when the button is clicked, so don't click the when this is actually clicked, what we are going to do first we are going to get the parameter from the tongue So he's going to say var equals dollars and select that input and an idea of time to do dot Val to get the value of it.

And just confirm again, the correct value, simple console log. So if I reload it, go to console, click that. Didn't even detect the nothing that you printed out. So it says custom speed button. No hash. So he's trying to find the element called cost of the button but not more of an ID.

You print a zero as a 400. It prints off. Okay. Pretty cool stuff. Now, what we're going to do is do this exact line or almost this exact line and Instead of toggling like that will probably be totally with time. And now if we run it okay.

Okay, so what is happening here? So I believe what is happening by the looks of it because in unnaturally getting this value, and you say text value, it is you know failing. And if it doesn't accept a valid value, it just defaults to the slow method. So we want to pass the integer. So what we want to do is pause. Int now if we wanted to do it Now it's working nice getting an integer value instead of just a string, and I thought provide the value are pretty good.

You know, pretty fast. If I do 10 seconds, I think they, you know, it's trying to do it or wait till it's not completed. But if it is extremely slow, let's say for the 2000s of two seconds, I toggle it on and off. So that's how you highly show and toggle something. They you can also use a speed parameter the built in a little slow and fast, or you can use a manual one last. Luckily, the one last thing I want to show you, and it is this, you can do this with any of these whatsoever.

So what you can do once you've called a speed, you can provide an optional callback. So, you know, in a similar way, we've got here you can do that. So let's say which is doing after the comma after your speed. And I think function I'll do console dot log. Again, you can do what you want to have to be a console log on the say. Finished.

So far reload. Click that. I think they finished. But what happened if I do 1000? clicker? I think he took a little while for it to pay, it took a second.

So this callback is triggered. Once this toggle effect is our display. No particular hide show or toggle effect is finished. Once it's finished. This code inside is triggered. Obviously, you could call a normal function from the app.

This thing itself could be a function call. Does simple stuff. If you understand This concept, you're all good to go. If you have any questions, feel free to pop me a message. And as usual, I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.