我使用以下javascript来允许我在点击时突出显示tr行
$(document).ready(function () {
$('tr').click(function () {
if(this.style.background == "" || this.style.background =="white") {
$(this).css('background', '#D3D3D3');
}
else {
$(this).css('background', 'white');
}
});
});
$('table tr').click(rowclick)
但如果我选择this,它就不起作用,我无法理解为什么它使用相同的代码
完整的JavaScript如下
var ie = document.all
var ns = document.getElementById && !ie
function rowclick(e) {
var obj = ns ? e.target : event.srcElement
if (obj.tagName=="TD") {
obj.onblur=function() {
}
}
}
$(document).ready(function () {
$('tr').click(function () {
if(this.style.background == "" || this.style.background =="white") {
$(this).css('background', '#D3D3D3');
}
else {
$(this).css('background', 'white');
}
});
});
$('table tr').click(rowclick)
document.onclick=rowclick
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([ <?php echo $data; ?> ]);
var data2 = google.visualization.arrayToDataTable([ <?php echo $datagoing; ?> ]);
var options = {
backgroundColor: 'transparent',
legend: 'none',
height: '100px',
width: '100px',
chartArea: { height :"95%", width:"95%" },
};
var options2 = {
backgroundColor: 'transparent',
legend: 'none',
height: '100px',
width: '100px',
chartArea: { height :"95%", width:"95%" },
};
var chart = new google.visualization.PieChart(document.getElementById('piechart<?php echo $loop ?>'));
chart.draw(data, options);
var chart2 = new google.visualization.PieChart(document.getElementById('piechartgoing<?php echo $loop ?>'));
chart2.draw(data2, options2);
}