views:

52

answers:

1

How to show and hide one particular column in Mouse Over and Mouse out receptively. on mouse over i want to show column in a single row and on mouse out i want to hide the column in that particular row.

any answer will help me

thanks in advance.

A: 

Use something like $(".TableRowClass").mouseOver(function(){ $("#colName").addClass("show")});

And to hide simply use mouseOut and removeClass("show");

This is of course untested but if you need specific code then let me know and I'll post code.

Edit

I should mention that the code is in jQuery.

Edit 2

The below works just fine. Some tweaking required.

   $(".hideShowSample").mouseover(function() {
        $(".hideShowSample #colToHide").removeClass("hideColumn");
    });
    $(".hideShowSample").mouseout(function() {
        $(".hideShowSample #colToHide").addClass("hideColumn");
    });
<style>
    .hideShowSample {}
    .hideColumn { display:none; }
</style>

<table>
    <tr class="hideShowSample">
        <td>$100.00</td>
        <td>Cheap stuff to buy.</td>
        <td id="colToHide" class="hideColumn">Backordered</td>
    </tr>
</table>
griegs
I personally would suggest $("#colName").hide(); and $("#colName").show(); cleaner css and you can set the time or "slow"
Hurricanepkt
Not a bad idea @Hurricanepkt if the goal is for animation yeah.
griegs
Hm, I am not sure about setting display:none for a table cell. This _might_ cause akward behaviour for the whole table if it contains more then one row. I normally avoid this and rather put a <div> inside the <td>, and then hide that <div> like so: .hideColumn { visibility:hidden } that also prevents the <td> from "jumping" into view when it contains larger content.
Max
@griegs thanks it works but when i get more rows using foreach means its not working. for each row if i make mouse over means it want to show the particular column.
kart
That's entirely valid @Max and a pretty good point. I think if you put all three of these posts together you'd have a damn good solution.
griegs
@unknow, each column must have a unique id and you must reference that id within the jQuery. You might wish to put in place what max suggested which meand you could do something like ".hideShowSample .colToHide div".hide("slow"); Untested but looks about right.
griegs
In which case replace the id with "" and change the class to "colToHide" and set the display of the div within the td to none. Make sense?
griegs