javascript - creating an inline update field using jquery -



javascript - creating an inline update field using jquery -

i've gotten stuck(again)

i have table , 1 of columns value want able click, turn input field, click 1 time again alter text.

i've gotten first step done. turns input field link click , uses value in td.

however, in writing function update value , remove input, can't fire @ all. i've tried copying out input field , hard coding first step page , when fire click function. (i haven't finished writing step wanted function fire first. below code. help overwhelmingly appreciated!

html:

<table> <tr id="1"><td class="qty" set="0" >2</td></tr> <tr id="2"><td class="qty" set="0" >2</td></tr> <tr id="3"><td class="qty" set="0" >2</td></tr> </table>

jquery:

$(".qty").click(function(){ var value = $(this).text(); var set =$(this).attr('set'); if (set==0){ $(this).html('<input type="text" name="quantity" value="'+value+'"><a href="#" class="update_qty">update</a> </span>'); $(this).attr('set', '1'); } }); $(".update_qty").click(function(){ alert("using check if it's firing"); });

you need utilize live() function, otherwise event won't added newly created elements.

$(".update_qty").live('click',function() { alert("check if firing"); });

javascript jquery

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -