I am new in Javascript, So I have small problem, First here is my live Code & written here.
this is my index.php file
<ul id="friends">
<li id="Maxi" class="user">Maxi</li>
<li id="John" class="user">John</li>
<li id="Henry" class="user">Henry</li>
<li id="Max" class="user">Max</li>
<li id="Simon" class="user">Simon</li>
</ul>
<div id="windows"></div>
It is my stylesheet page.
.user{
text-align:center;
width:50px;
height:20px;
display:inline-block;
background-color:#9B59B6;
margin:5px;
border:4px solid #3498DB;
color:#F1C40F;
cursor:pointer;
float:right;
}
.mwindow{
width:150px;
height:200px;
border:2px solid #16a085;
}
.mwindow{
width:140px;
height:25px;
background-color:#1abc9c;
padding:5px;
}
.cls{
display:inline-block;
float:right;
cursor:pointer;
font-size:20px;
font-weight:bold;
}
And it is my js page
$(document).ready(function(){
$('.user').click(function(){
var id = $(this).attr("id");
$html = '<div class="mwindow"><div class="hwindow">'+id+'<span class="cls">x</span></div></div>';
$('#windows').append($html);
});
});
$(document).ready(function(){
$('#friends').on('click','.user', function(){
$('.mwindow').hide();
});
});
So my problem is when I click on one of users then display is showing none instead of display block.
$('.mwindow').hide();???$('.mwindow').hide();hides all elements with that class. What do you want to happen instead?$('.mwindow').hide(); this should work when i click on .mwindowBUT you are binding it on.userclick...