javascript - Using jQuery to Select a DIV that exists only on mouseover -


i have couple of div not exist until user places mouse on img causes div popup, done via google maps api. how can use jquery select div when created (pops on screen)?

current code:

$(function() {     var height = $("#infobox_content").height();     $("#infobox").css('height', height);     

});

this not work because div not exist yet.


update


php code creates div popsup when mouseover google map marker note every set of <div> created has same id infobox, infobox_content. can add number make them unique need change css stylesheet select infobox1, infobox2, infobox3.... infobox10

foreach($config['markers'] $marker) {             $marker_number++;              $map_js .= '             var boxtext = document.createelement("div");             boxtext.style.csstext = "";             boxtext.innerhtml = "<div id=\'infobox\'> \                                     <div id=\'infobox_content\'> \                                         <strong>'.$marker['name'].'</strong><br /> \                                         <p class=\'infobox_content\'> \                                             143 1st st<br> \                                             cambridge ma 021232 \                                     </div> \                                 </div>";              var myoptions = {                  content: boxtext                 ,disableautopan: false                 ,maxwidth: 0                 ,pixeloffset: new google.maps.size(-40, 0)                 ,zindex: null                 ,boxstyle: {                      background: "none",                     opacity: 0.85                  }                 ,closeboxmargin: "10px 2px 2px 2px"                 ,closeboxurl: ""                 ,infoboxclearance: new google.maps.size(1, 1)                 ,ishidden: true                 ,pane: "floatpane"                 ,enableeventpropagation: false                 ,infoboxclearance: new google.maps.size(10, 10)             };              var infobox'.$marker_number.' = new infobox(myoptions);             infobox'.$marker_number.'.open(map, marker'.$marker_number.');             ';         }  

php code generates javascript google maps api:

foreach($config['markers'] $marker) {             $marker_number++;             $map_js .= ' 

/* part handles mouseover */

            google.maps.event.addlistener(marker'.$marker_number.', "mouseover", function(event) {                 infobox'.$marker_number.'.show();                  var height = $("#infobox_content").height();                 $("#infobox").css("height", height);              }); } 

***the result of above code $("#infobox").css("height", height) applied first <div> created...

note every set of created has same id infobox, infobox_content. can add number make them unique need change css stylesheet select infobox1, infobox2, infobox3.... infobox10

ids must unique.

trying select id when there multiple on page give first match.

in case, should use class instead of id since they're repeating, , use class in css styling.

beyond that, if posted code rendered client instead of server-side code, may add clarity best solution.

.live() nothing here unless you're trying associate event handlers new elements.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -