
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 0.95 KB | hits: 14 | expires: Never
How to use position in CSS?
<table id="tab">
<tr><td class="here">dgd</td><td class="here">dfg</td></tr>
<tr><td class="here">fgf</td><td class="here">sg4</td></tr>
</table>
<table id="new">
<tr><td id="al">sss</td></tr>
</table>
#tab td {
padding: 5px;
border: solid 1px red;
}
#new td {
padding: 5px;
height: 40px;
border: solid 1px green;
background-color: green;
}
#new {
display: none;
}
$(".here").click(function(){
$("#new").show();
})
$("#al").click(function(){
alert('ok');
})
$('.item').click(function(event){
$('#context').show();
event.stopPropogation();
});
$('body').click(function(){
$('#context').hide();
});
$(document).on("click", function(e) {
var $el = $(e.target);
if ($el.hasClass("here")) {
$("#new").css({'left': e.target.offsetLeft,
'top': e.target.offsetTop}).show();
} else {
$("#new").hide();
}
});