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);
});
});
精彩评论