誰かがクリックしたときにテーブルの行を強調表示しようとしています。これが私のテーブルです:
<table class="pretty">
<tr>
<td onclick="DoNav('<?php echo $url; ?>');">Name</td>
<td onclick="DoNav('<?php echo $url; ?>');">Time</td>
<td onclick="DoNav('<?php echo $url; ?>');">Size</td>
<td onclick="DoNav('<?php echo $url; ?>');">Length<td>
<td><input type="checkbox" value="<?php echo $this->result_videos[$i]["video_name"]; ?>" title="Mark this video for deletion" /></td>
</tr>
...
私はこの投稿に基づいていくつかのことを試しました:
jQuery("table tr").click(function(){
var row = jQuery(this);
var hasClass = row.hasClass("highlight");
jQuery("table tr").removeClass("highlight");
if(!hasClass){
row.addClass("highlight");
alert("Do I get here?");
}
});
私のcss。編集:問題になる可能性のある完全なCSSを追加しました:
table.pretty {
width: 100%;
border-collapse: collapse;
font-family: "Lucida Sans Unicode","Lucida Grande",Sans-Serif;
clear: both;
}
/* Header cells */
table.pretty thead th {
background: none repeat scroll 0 0 #808184;
border-bottom: 1px solid #2B3D61;
border-top: 4px solid #2B3D61;
color: #ffffff;
font-size: 14px;
font-weight: normal;
padding: 8px;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
text-align: center;
}
/* Body cells */
table.pretty tbody th {
background: none repeat scroll 0 0 #808184;
border-bottom: 1px solid #2B3D61;
border-top: 4px solid #2B3D61;
color: #ffffff;
font-size: 14px;
font-weight: normal;
padding: 8px;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
table.pretty tbody td {
background: none repeat scroll 0 0 #eeeeee;
border-bottom: 1px solid #2B3D61;
border-top: 1px solid transparent;
color: #333333;
padding: 8px;
text-align: center;
}
table.pretty tbody tr {
cursor: pointer;
}
/* Footer cells */
table.pretty tfoot th {
background: none repeat scroll 0 0 #808184;
border-bottom: 1px solid #2B3D61;
border-top: 4px solid #2B3D61;
color: #ffffff;
font-size: 14px;
font-weight: normal;
padding: 8px;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
text-align: left;
}
table.pretty tfoot td {
background: none repeat scroll 0 0 #808184;
border-bottom: 1px solid #2B3D61;
border-top: 4px solid #2B3D61;
color: #ffffff;
font-size: 14px;
font-weight: normal;
padding: 8px;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
text-align: center;
}
.highlight{
background-color: #a8cb17;
}
どういうわけか、行の色は変わりません。行をクリックするとビデオを開始するDoNav関数にjqueryコード(クリックを差し引いたもの)を入れてみました。
私は何を間違っているのですか。前もって感謝します。