Browsing Different Content In A Jquery Dialog Without Using Tabs
I am creating a jQuery UI Dialog box, with 3 buttons in it, such that I can display different content in the dialog box according to the different buttons I have clicked. And befo
Solution 1:
Create 3 different div for the 3 different buttons no seperate html is required
$(document).ready(function() {
$('li:first-child, #i1').click(function() {
$('#main button').css({
'display': 'inline-block'
});
$('#i1').addClass("active");
$('#i3,#i2').removeClass("active");
$('#info1').css({
'display': 'block'
});
$('#info2,#info3').css({
'display': 'none'
});
})
$('li:nth-child(2), #i2').click(function() {
$('#main button').show();
$('#i2').addClass("active");
$('#i1,#i3').removeClass("active");
$('#info2').css({
'display': 'block'
});
$('#info1,#info3').css({
'display': 'none'
});
})
$('li:nth-child(3), #i3').click(function() {
$('#main button').show();
$('#i3').addClass("active");
$('#i1,#i2').removeClass("active");
$('#info3').css({
'display': 'block'
});
$('#info2,#info1').css({
'display': 'none'
});
});
});
#info1,
#info2,
#info3 {
display: none;
position: absolute;
top: 70px;
background: #454545;
width: 300px;
height: 500px;
color: white;
}
.active {
background: green;
}
ulli {
display: inline-block;
list-style-type: none;
background: lightblue;
border: 1px solid black;
}
button {
display: none;
border: 1px solid black;
}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divid="main"><ul><li>1nfo</li><li>info2</li><li>info3</li></ul><buttonid="i1">info1</button><buttonid="i2">info2</button><buttonid="i3">info3</button><divid="info1">description of info1</div><divid="info2">description of info2</div><divid="info3">description of info3</div></div>
Post a Comment for "Browsing Different Content In A Jquery Dialog Without Using Tabs"