How to call a Function on load of Div tag
How to call a function on load of Div tag?
First function:
{
var name=$(link).attr('value')+"_con";
$("#content").append("<div id='name' style='width:100%; height:100%'><div>");
initialize(name);//It will create a map inside Div content
$("#"+name).show();
}
In other function I call the Div to show:
Second function:
{
$("#"+name).show();//It displays only the Div content..How to show Div content with that initilize(开发者_如何转开发name) function
}
you post your variable as a string and not as a js variable.
$("#content").append("<div id='"+name+"' style='width:100%; height:100%'><div>");
and than
$("#"+name).live('load', function () {
//do stuff
})
put all under document ready.
Maybe this will help: http://jsfiddle.net/7ZSAR/
Html:
<div id="content"></div>
JS:
$(document).ready(function()
{
//var name=$(link).attr('value')+"_con";
var name="something"; //Needed to hardcode this for example.
$("#content").append("<div id='"+name + "' style='width:100%; height:100%'><div>");
initialize(name);//It will create a map inside Div content
$("#"+name).show();
});
function initialize(id){
$("#" + id).html("<div>My Map </div>");
}
精彩评论