Making a TD clickable

前端 未结 7 508
有刺的猬
有刺的猬 2020-12-09 03:41

I\'ve set up a fiddle with a table.

You see, Im trying to make a table where the user will hover and click the td to show an id. Check the fiddle out and you\'ll und

相关标签:
7条回答
  • 2020-12-09 04:46

    The href property is designed for anchor elements (<a/>). "ahref" as you've put should be <a href="">. a is an element of its own, not a HTML attribute, and href is an attribute it accepts.

    To make the text of a td clickable you can simply put an anchor within it:

    <td>
        <a href="#child4">My clickable text</a>
    </td>
    

    Edit: To fix this now that the question has been added, simply add in the following CSS:

    td a {
        display:block;
        width:100%;
    }
    

    What this does is display the anchor tag as a block, allowing us to adjust the width, and then set the width to 100%, allowing it to fill the remaining space.

    Working JSFiddle.

    0 讨论(0)
提交回复
热议问题