开发者

How to perform an activity using Jquery on page load

开发者 https://www.devze.com 2022-12-20 19:54 出处:网络
I have below code in Jquery $(document).ready(function() { // bind to cells with an ID attribute $(\"table > tbody > tr > td[id]\").mouseover(function() {

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开发者_如何学JAVA 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!


replace mouseover with each and youll have the desired functionality.


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);
  });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号