如何在链接中包装表格? [英] How to wrap a table in a link?
问题描述
哪些元素允许链接?
我想换行围绕表的链接
,
< a href =123.phpclass =grap>
< table border =1style =width:600px; height:600px;>
< tbody>
< tr>
< td align =centerstyle =border:1px solid red>< img src =thumb-pic-1.jpgalt =123/>< / td>
< / tr>
< / tbody>
< / table>
< / a>
但它不是正确的html,如 http://validator.w3.org/
我可以将链接放在表单中像这样,
< form action =123.phpclass =grap>
< table border =1style =width:600px; height:600px;>
< tbody>
< tr>
< td align =centerstyle =border:1px solid red>< img src =thumb-pic-1.jpgalt =123/>< / td>
< / tr>
< / tbody>
< / table>
< / form>
但是链接
或 table
并不意味着表单提交...
我不知道是否有任何方法来包装表格链接?
编辑:
抱歉忘记提及我需要抓取链接网址就像这样,
$('。grap')。click(function(){
alert( $(this).attr('action'));
return false;
});
浏览器可让您在链接中包装表格。与它有关的实际问题与渲染有关(浏览器可能会或可能不会在文本内容下划线,并且在链接内部围绕图像绘制边框),而不是基本功能。例如,它根据HTML 4.01无效,但那又如何?
在您的示例中,表格仅包含一个仅包含一个图像的单元格。您可以改为使用 img
元素并对其进行适当的设置。在更复杂的情况下,表格可能很有用。那么你应该在CSS和 border 中为它设置
color
和 text-decoration
code>包含在其中的任何 img
,这样你就可以得到你喜欢的渲染,而不是像这样的情况下不同的浏览器默认渲染。
What elements allow link?
I want to wrap a link around a table
,
<a href="123.php" class="grap" >
<table border="1" style="width:600px; height:600px;">
<tbody>
<tr>
<td align="center" style="border:1px solid red"><img src="thumb-pic-1.jpg" alt="123"/></td>
</tr>
</tbody>
</table>
</a>
But it is not a correct html as in http://validator.w3.org/
I can put the link in a form like this,
<form action="123.php" class="grap" >
<table border="1" style="width:600px; height:600px;">
<tbody>
<tr>
<td align="center" style="border:1px solid red"><img src="thumb-pic-1.jpg" alt="123"/></td>
</tr>
</tbody>
</table>
</form>
But the link
or the table
is not meant to be a form form submission...
I wonder if there are anyway to wrap a table in a link?
EDIT:
Sorry forgot the mention that I need to grab the link url like this,
$('.grap').click(function(){
alert($(this).attr('action'));
return false;
});
Browsers let you wrap a table inside a link. The practical problems with it relate to rendering (browsers may or may not underline the text content and draw borders around images inside a link), not with basic functionality. It’s not valid as per HTML 4.01 for example, but so what?
In your example, the table contains just one cell that contains just one image. You could instead use just an img
element and style it suitably. In a more complicated case, a table might be useful. Then you should probably set color
and text-decoration
for it in CSS and border
for any img
contained in it, so that you get the rendering you prefer and not the varying browser default rendering for a situation like this.
这篇关于如何在链接中包装表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!