php - related width of tow elements -
i have problem ,i want relate width of tow elements, first simpl div , second span ... write code:
<div id="wb_name_to_menu" style="position:absolute;left:768px;top:20px;width:171px;height:18px;z-index:4;"> <span id="sp_name_to_menu" style="color:#ff0000;font-family:arial;font-size:16px;">love me!</span></div> <div id="layer_to_mainu" style="visibility: hidden;position:absolute;text-align:left;left:772px;top:22px;width:132px;height:135px;z-index:132;" title=""> <div id="wb_main_mainu" style="position:absolute;left:8px;top:9px;width:123px;height:28px;z-index:1128;padding:0;"> <div id="main_mainu"> <ul style="display:none;"> <li><span></span><span id="id_full_name_from_main_menu">love meeeeee</span> <ul> <li><span></span><span>account sitting</span></li> <li><span></span><span>help</span></li> <li><span></span><span>log out</span></li> </ul> </li> </ul> </div>
in javascript , do:
$(document).ready(function(){ $("#wb_name_to_menu").hover(function(){ $("#layer_to_mainu").css("visibility","visible"); $("#layer_to_mainu").css("width",$("#id_full_name_from_main_menu").width()+"px"); }); }); $(document).ready(function(){ $("#layer_to_mainu").mouseleave(function(){ $("#layer_to_mainu").css("visibility","hidden"); }); });
it doesnt work !! , konw cause : causde $("#id_full_name_from_main_menu").width() gived null value !!! can 1 me please :)
$("#id_full_name_from_main_menu").width()
returns 0 because ancestor <ul>
has display:none
set. read width might want remove attribute, or temporarily change in js, depending on you're trying do
$(document).ready(function(){ $("#wb_name_to_menu").hover(function(){ $("#layer_to_mainu").css("visibility","visible"); $("#main_mainu > ul").css("display","block"); $("#layer_to_mainu").css("width",$("#id_full_name_from_main_menu").width()+"px"); $("#main_mainu > ul").css("display","none"); });
that won't display text update width of #id_full_name_from_main_menu, need remove display:none
see text appear.
Comments
Post a Comment