tags:

views:

22

answers:

2

Hi,

I have below code in Jquery

$(document).ready(function() {

    // bind to cells with an ID attribute
    $("table > tbody > tr > td[id]").mouseover(function() {

        // grab the anchor from the LI whose ID starts with the cell's ID
        var $tooltip = $("div:hidden li[id^=" + $(this).attr("id") + "] a");

        // append it to the current cell
        $(this).append($tooltip);
    }).mouseout(function() {

        // remove the anchor/tooltip
        $(this).find("a").remove();
    });
});

Now you can see in above code that certain things has been done on MOUSEOVER event. The issue is that it does not show my anchor tag until I have MOUSEOVER on that particular TD. I want when my page gets loaded it will show all the anchor in TD without any MOUSEOVER or any EVENTS.

I want to write this code on page load event, please suggest!

+2  A: 

replace mouseover with each and youll have the desired functionality.

alemjerus
Thanks Dear for your help!
MKS
A: 

try something like this:

$(document).ready(function() {
  $.map( $("table > tbody > tr > td"), function(elem){
    var tooltip = $("div:hidden li[id^=" + $(elem).attr("id") + "] a");
    $(elem).append(tooltip);
  });
});
makevoid