JSFiddle - React, Tailwind, and code Playground
123
by ysuper
HTML
<table class="table table-hover table-bordered searchable">
<!-- <table class="abc"> -->
<tr>
<td>
<b>進貨單別</b>
</td>
<td>
343
</td>
</tr>
<tr>
<td>
<b>進貨單號</b>
</td>
<td>
20181108007
</td>
</tr>
<tr>
<td>
<b>供應廠商</b>
</td>
<td>
凌華科技股份有限公司
</td>
</tr>
<tr>
<td>
<b>單據日期</b>
</td>
<td>
20181108
</td>
</tr>
<tr>
<td>
<b>進貨日期</b>
</td>
<td>
20181108
</td>
</tr>
</table>
JavaScript
$(".table.table-hover.table-bordered.searchable tr").each(function() {
$(this).find("td").each(function() {
if ($(this).text().trim() == '進貨單別') {
alert($(this).next().text());
var newString = "";
switch ($(this).next().text().trim()) {
case "341":
newString = "341 (月結進貨單)"
break;
case "342":
newString = "342 (國外隨貨進貨單)"
break;
case "343":
newString = "343 (國內隨貨進貨單)"
break;
case "344":
newString = "344 (緊急進貨單)"
break;
case "282":
newString = "282 (多角採購銷貨單)"
break;
default:
newString = $(this).next().text().trim() + " (未定義的表單)"
}
$(this).next().text(newString);
alert($(this).next().text());
}
});
});