//ROZWIĄZANIE
zamiast
$(this).addClass('click');
należy
$(this).toggleClass('click');
drugie starcie z jQuery

napisałem prosty kod, i teraz nie wiem jak dopisać by po drugim kliknięciu odznaczyło mi row tabeli
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
#mytable
{
border: 1px solid black;
}
#mytable th, #mytable td
{
border: 1px solid #000;
padding: 3px;
}
#mytable tr.highlight
{
background-color: #b02329;
}
#mytable tr.click
{
background-color: yellow;
}
<script type="text/javascript"> $(function()
{
$('#mytable tr').hover(
function()
{
$(this).addClass('highlight');
},
function()
{
$(this).removeClass('highlight');
})
});
$(function()
{
$('#mytable tr').click(
function()
{
$(this).addClass('click');
}
)
}
);
<td>lorem ipsum stabat
</td> <td>lorem ipsum stabat
</td> <td>lorem ipsum stabat
</td> <td>lorem ipsum stabat
</td> <td>lorem ipsum stabat
</td> <td>lorem ipsum stabat
</td> <td>lorem ipsum stabat
</td> <td>lorem ipsum stabat
</td> <td>lorem ipsum stabat
</td> <td>lorem ipsum stabat
</td> <td>lorem ipsum stabat
</td> <td>lorem ipsum stabat
</td>
Ten post edytował john_doe 4.06.2010, 10:26:58