0

I have a drop down menu that is a table and table rows. Each row contains a word which is a hyperlink text. I would like the blank space following the hyperlink word to be a link to the same url as the text itself.

This is what i have so far

<TR ID="opt_1" onclick href="boom.php?catname=booyah " ONMOUSEOVER="hiLiteM('01'); hiLite('1')" ONMOUSEOUT="unLite('1'); unLiteM('01')" ><TD> <a onclick href="boom.php?catname=booyah ">booyah</A></TD></TR>

This doesn't work, are the any suggestions for me to achieve success, thank you

2
  • One interesting thing I find is that you are capitalizing almost every tag, and the onclick is empty for no apparent reason. Enlighten me, why do you do that?
    – Ben
    May 10, 2015 at 4:08
  • temporary retardation
    – peter
    May 10, 2015 at 4:11

3 Answers 3

1

You can style the anchor as a block element and it will fill the entire cell. Since there's only one cell in your row, I think this should accomplish what you want without need for javascript:

<tr id="opt_1">
    <td><a style="display: block" href="boom.php?catname=booyah">booyah</a></td>
</tr>

See JSFiddle

I'm not sure what those mouseover and mouseout functions do but I'm assuming they are styling changes that could just as easily be accomplished with CSS.

0
<TR ID="opt_2" onClick="location.href='brands.php?catname=Asprey'" ONMOUSEOVER="hiLiteM('01');hiLite('2')" ONMOUSEOUT="unLite('2'); unLiteM('01')"><TD><A  onclick href="brands.php?catname=Asprey">Asprey</A></TD></TR>

This is my solution. does anyone have anything better?

0

Yes you can make the whole td as hyperlink by placeing anchor tag inside td and giving class with width of 100% to anchor tag.

JSFiddle

CSS

table { width: 300px; }

table, table tr, table td
{
margin:0%;
}

.td-link
{
    display:inline-block;
    width:100%;
    background:aqua;
}

a
{
   text-decoration:none;
    color:black;    
}

HTML

<table>
    <tbody>
         <tr>
             <td>
                 <a href="abc.html" class="td-link">TD is made link now </a>
             </td>
        </tr>
    </tbody>
</table>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.