jquery - PHP 中的行跨度 table

jquery - Rowspan table in PHP

它作为 .text in td

   <td>'.$row["j_pic"].'</td>

it works.jpg

但它不适用于 td

中的 img

<td>'."<img src='picture/".($row["j_pic"])."' style='width:20%' />".'</td>

it not works.jpg

jQuery

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
$(document).ready(function() { 
var span = 1; 
var prevTD = ""; 
var prevTDVal = ""; 
$("#myTable tr td:first-child").each(function() { //for each first td in every tr 
var $this = $(this); 
if ($this.text() == prevTDVal) { // check value of previous td text
span++; 
if (prevTD != "") { 
prevTD.attr("rowspan", span); // add attribute to previous td $this.remove(); // remove current td 
} } else { 
prevTD = $this; // store current td 
prevTDVal = $this.text();
span = 1; } }); });

我想你想比较 HTML 内容然后使用 html() method instead of text() method since text() 方法只是 returns 元素内的文本内容。

if ($this.html() == prevTDVal)