javascript - Positioning Element Relative to its Friend Element -


i create effect same position relative in css using jquery.

i have created type of tooltip trying attach different objects such textboxes, checkboxes, text etc.

so code along lines of

<input id="adsfjlk" type="textbox" /> <div class="tooltipballoon"> text</div> 

now of course css relative positioning based on elements parent. cannot in case cannot place div inside of input element.

currently use jquery position tooltip right of textbox.

the problem comes when on page changes. example if have elastic textarea above textbox. when expands pushes down textbox , tooltip no longer aligned correctly.

because of amount of different things happen cannot apply onchange type event elastic , instead need better way keep elements positioned relative each other.

i'm not sure how displaying tooltips (on focus, on hover), have created example of how may create tooltips inputs.

http://jsfiddle.net/c4kyd/2/

i followed each input span tag containing tooltip. positioned span 'absolute'. tooltip displayed on focus , removed on blur.

if there dynamic content on page tooltips still positioned correctly (if comment out blur function , use "change page" link insert content you'll see in action).

i created code hover events (commented out in example).

here snippets of code.

html...

<ul class="tooltip-stuff">   <li>     <label>first name</label>     <input class="tooltip" type="text" />     <span>enter first name here.</span>   </li> </ul> 

css...

 .tooltip-stuff span {     border: 1px solid #d3d3d3;     margin-left: 5px;     padding: 0 6px;     background-color: #c4ecf8;     position: absolute;     display: none; } 

jquery...

     $('.tooltip').focus(function () {         $(this).next('span').fadein(100);     });      $('.tooltip').blur(function () {         $(this).next('span').fadeout(100);     }); 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -