doutang6600 2016-04-04 14:30
浏览 40

使用jQuery调用填充DIV时不应用CSS样式

I am populating a <DIV id='area'> element using a PHP script and I want to repopulate the same DIV element by calling a PHP function in JavaScript if the user wishes to filter the information:

$("#area").load("update-dashboard.php?id=7263");

It populates the DIV element with the correct information but the CSS styling I'm using to format the information (eg. class="highlight") doesn't get applied for some reason. So what I get reads correctly if I view the underlying HTML but the browser doesn't format it according to the stylesheet.

<style type="text/css">
.Highlight {
 background-color: #dcfac9;
 cursor: pointer;
}
td.highcell {
 padding-top: 8px;
 padding-bottom: 8px;
}
</style>

Here's what my table should contain within the DIV section:

<table style='border-collapse: collapse;' border=0 width='100%' id='link-table'>
<tr class='highlight'>
<td class='highcell'>
<a href="javascript:ShowWait('754', 'Car Survey', '16', 'NK51+SNR55', '', '');">NK51 SNR55</a>
</td>
<td class='highcell' width=36>
<img src='status_2.png' border=0 width=32 height=32><td class='highcell'>18-Dec-15</td>
<td class='highcell'>NK51 SNR55</td>
<td class='highcell'></td>
<td class='highcell'></td>
</tr>

ADDITIONAL INFO: I also use this jQuery code to highlight the rows in the Table - maybe it doesn't work with HTML loaded after the page appears - if so can it be reinitialised?

$(function ()
{
 $('#link-table td:first-child').hide();
 $('#link-table tr').hover(function ()
 {
  $(this).toggleClass('highlight');
 });
 $('#link-table tr').click(function ()
 {
  location.href = $(this).find('td a').attr('href');
 });
});
  • 写回答

1条回答 默认 最新

  • dqwp81696 2016-04-04 14:46
    关注

    Try changing your css from .Highlight to .highlight. CSS selectors are case-insensitive but the HTML class attributes are not.

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘