html, javascript: scrolling through list box items - and display prompt for each item -


so need following: when select item list box need able dynamically display additional information item in separate box. i.e. let's i'm scrolling through list of cars, each car select display price, color, mileage etc. idea similar in , feel prompt pops next element when use hovers-over. in other words ideally i'd see small box magically pops-up right next item required information. recommendations on how implement that?

update: clarify i'm looking for. ended implementing responding change() event , manually updating html element defined particula purpose, 1 of answers below suggests:

$('#available-elements').change(function() {     var id = $(this).val();     var element = find_element(id);//retrieve complete element info     $('#the_prompt').show();     $('#prompt_name').find('td').text(element.title);     $('#prompt_datatyp').find('td').text(element.datatype);          $('#prompt_groupcode').find('td').text(element.groupcode); }); 

the prompt element defined follows:

    <table id="the_prompt" style="border:2px solid grey;">       <tr id='prompt_name'><td class="rate_prompt"></td></tr>       <tr id='prompt_datatyp'><td class="rate_prompt"></td></tr>       <tr id='prompt_groupcode'><td class="rate_prompt"></td></tr>      </table> 

but hoping there plug-in fro or something. especially, hoping avoid defining static html element pre-defined location, size etc. , updating content manually. instead, i'd love see prompt, similar hover-over help, right next clicked list element, arrow pointing clicked element. i'm still relatively new jquery i've been impressed capabilities , plugins idea above did not seem unrealistic me.

this solution shows description taken data attribute in fixed div , adjusts position of infobox when hovering on list items:

jquery code:

$(document).ready(function(){     var lastli = null;     var ci = $('#carinfo');     $('.carlist li').hover(function(e){         if (lastli == this) { return; } else {}         var top = e.pagey;         var left = e.pagex;         if (left+100 > $(window).width()){             left -= 100;         }         ci.html($(this).data('info'));         ci.css({'top':top, 'left': left}).show();     },function(e){         var elt = e.toelement || e.relatedtarget;         if (elt != && elt != ci[0]) {             ci.hide();             lastli = null;         } else {             lastli = this;         }     });     ci.mouseleave(function(e){         var elt = e.toelement || e.relatedtarget;         if (elt!=lastli) {             ci.hide();             lastli = null;         }     }); }); 

html sample:

<ul class="carlist">     <li data-info="2004 ford ranger xlt 2.3l 2wd 125758 miles $5,988">         2004 ford ranger     </li> </ul>  <div id="carinfo"></div> 

css:

ul.carlist {      list-style:none;     padding:0; }  ul.carlist li {     padding: 5px;     margin: 5px;     background-color:#eef; }  #carinfo {     position:absolute;     display:none;     background-color: white;     border:1px solid red; } 

demo


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -