PEAR HTML_TABLEを使って、データベースからテーブルの表示を作成しています。
空白のフィールドがあるので、そこを画像で自動的に埋めようとしています。カラム別に交互で別の画像を使いたいので、下記のコードを使用しております。
$attrs_array = array( 'class' => 'example_main',
'id' => 'example_main_id',
'width' => '100%',
'border' => '2',
'cellspacing' => '0',
'cellpadding' => '0');
$table = new HTML_Table($attrs_array);
$table->setAutoGrow(true);
$table->setAutoFill("<span class='icon_img'></span>");
JavascriptとjQueryを使っているのですが、うまくいきません。
Javascript(Jquery)には下記を使っています。
$(".example_main td:not(.jobCell):not(.tJCell)").each(function(){
var col_index = $(this).cellPos().left;
var pre_col = col_index % 2;
if (pre_col == 0){
$(this).text( 'Even');
//$(this).attr( 'src', '../img/buttons/list.png');
}else{
$(this).attr( 'src', '../img/buttons/btn_pointer.png');
}
});
上記のJavascriptは、奇数と偶数のテキストをセルに入れる作業はうまくいっています。
ただ前述の通り、テキストではなく画像が必要なのです。
CSSを使っても試したのですが、下記のコートではうまくいきませんでした。
.icon_img
{
background-image:url(../../img/buttons/list.png);
}
どうしたらいいか分かるかたいませんか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。