Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Slider Control in JQuery
WhatsApp
Vipul Kelkar
13y
6.4
k
0
0
25
Blog
In this blog we will write what I call it as a slider web part control using JQuery. Please suggest a better name if you have any..
The control would work something like this
Click on HIDE and the text slides UP
Create an HTML file with the following code
<
html
>
<
head
>
<
script
type
="text/javascript"
src
="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></
script
>
<
script
type
="text/javascript"
src
="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.min.js"></
script
>
<
style
type
="text/css">
div.panel
{
height
:
120px
;
width
:
500px
;
}
div.panel
,
p.para
{
margin
:
0px
;
background-color
:
#FFEECA
;
border-style
:
solid
;
border-width
:
1px
;
}
td.tdTitle
,
td.tdHideShow
{
border
:
1px
solid
black
;
background-color
:
#FFEECA
;
}
</
style
>
<
script
type
="text/javascript">
$(document).ready(
function
() {
$(
"#pHideShow"
).toggle(
function
() {
$(
"#panel"
).slideToggle();
$(
"#pHideShow"
).text(
"Show"
);
}
,
function
() {
$(
"#panel"
).slideToggle()
$(
"#pHideShow"
).text(
"Hide"
);
}
);
});
</
script
>
<
style
type
="text/css">
</
style
>
</
head
>
<
body
>
<
table
class
="Title">
<
tr
>
<
td
class
="tdTitle"
width
="450">
Your title goes here
</
td
>
<
td
class
="tdHideShow"
width
="40">
<
p
id
="pHideShow">
Hide
</
p
>
</
td
>
</
tr
>
</
table
>
<
div
class
="panel"
id
="panel">
<
p
>
Your text goes here
</
p
>
</
div
>
</
body
>
</
html
>
The “slidetoggle” method of jquery does the actual toggling of the control Up and Down. The TOGGLE method has been used to alternate the ‘hide' and ‘show' labels.
You can have your own stylings and make it more presentable. This is just to give a basic idea of the Toggle and slide toggle functions of JQuery. Hope this helps!
Slider Control in JQuery
Up Next
Image Slider Using jquery
Ebook Download
View all
Frontend Developer Interview Questions and Answers
Read by 940 people
Download Now!
Learn
View all
Membership not found