我在这里遇到了一些情况。 当我将 tr 更改为 ul 并将 td 更改为 li 时,链接有效,但在表中链接无效。 链接由永久链接和之后的代码获取
if (sizeof($allMessages)>0)
{
foreach($allMessages as $message){?>
<tr>
<a href="<?php echo get_the_permalink(); ?>?candidate-page=mailbox-readmail&messageId=<?php echo esc_html__($message['id'],'nokri') ?>" class="list-inline"><?php if(in_array("UNREAD", $message['labelIds'])){ ?><b class="list-inline">
<td class="posted-job-title"><?php echo esc_html__($message['email'] , 'nokri' ); ?></td>
<td class="posted-job-status"><?php echo esc_html__( $message['subject'], 'nokri' ); ?></td>
<td style="margin-right: 148px;" class="posted-job-status"><?php echo esc_html__( $message['from'], 'nokri' ); ?></td>
</b>
<?php } else { ?>
<td class="posted-job-title"><?php echo esc_html__($message['email'] , 'nokri' );?></td>
<td class="posted-job-status"><?php echo esc_html__( $message['subject'], 'nokri' ); ?></td>
<td style="margin-right: 147px;" class="posted-job-status"><?php echo esc_html__( $message['from'], 'nokri' ); ?></td>
<?php } ?>
</a>
<td>
<a href="<?php echo get_the_permalink(); ?>?candidate-page=mailbox-inbox&messageId=<?php echo esc_html__($message['id'],'nokri') ?>&delete=true" class="list-inline"><li class="posted-job-action"><i class="fa fa-trash" aria-hidden="true"></i></li></a>
</td>
</tr>
<?php
最佳答案
我认为表结构不应该是这样的。现在,您的表结构的简化版本如下所示:
<tr>
<a href="/content">
<td>Content here</td>
</a>
</tr>
<a>
标签位于 TR 元素内。
你试过把<a>
TD 元素中的标记?
<tr>
<td>
<a href="/content">Content here</a>
</td>
</tr>
<a>
标签现在位于表格单元格内,内容应该流畅。
还要查找任何语法错误。 祝你好运!
关于php - href 不适用于表 td,但适用于 ul li,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55185239/