javascript - How would you go about placing li in different divs? -


i have input box that, when type it, creates visible li word entered on it.

i trying make that, depending on user types (either number 1, 2, or 3), placement of li goes appropriate div (div1 if typed "1", div2 if typed "2", or div3 if typed "3").

and can't figure out how achieve this. can figure out how make pretty else change (the text color, background color, padding, etc) except getting right div!!

can done through css or jquery thing or what?

please give me ideas of go this.

 <input type="text" placeholder="type 1, 2, or 3 here." autocomplete="off"> 

in case, since value of input element , the sufix of div same, use add li

$('input').change(function () {     var value = this.value;     if ($.inarray(value, ['1', '2', '3']) > -1) {         $('<li />', {             text: value         }).appendto('#d' + value + ' ul')     } }) 

demo: fiddle

also note adding li ul element not div


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -