First way: (Simple point)
Modify Operation
function UpdateItem () {
Using Toggle Composite Events
$ ("input[type=button][value= modified]"). Toggle (function () {
Button becomes "OK"
$ (this). attr ("value", "OK");
Show text box and hide span
var $span = $ (this). Parent (). Parent (). Children (": EQ (1)"). Children (": eq (0)")
Get Focus and select
$span. Hide (). Next (). Show (). Val ($span. Text ()). focus (). Select ();
},function () {
Turn the button into "modify"
$ (this). attr ("value", "Modified");
Hide the text box and show span
var $input =$ (this). Parent (). Parent (). Children (": EQ (1)"). Children (": EQ (1)");
$input. Hide (). Prev (). Show (). Text ($input. Val ());
})
Title Picture:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7D/E8/wKioL1byoPLQe0BvAABf-z63VVY391.png "title=" o1}xi1 (ua[' k{{u ' 7iyo0]i.png "alt=" Wkiol1byoplqe0bvaabf-z63vvy391.png "/>
The second way: (more complex)
Modify method
function Updates () {
Find the subscript for each click
var $i = $ (this). Parents ("tr"). Index ()-1;
Modification of the current line and confirmation switch
$ (this). Hide (). Next (). Show ();
text box showing the current line
$ ("table"). Find (". X:eq (" + $i + ")"). Show ();
Get quantity
var $shul =$ ("Span:eq (" + $i + ")"). text ();
Hide Quantity to clear
$ ("Span:eq (" + $i + ")"). Hide (). empty ();
Assign a value to a text box
$ (". X:eq (" + $i + ")"). Val (parseint ($shul));
Click Confirm to pass the value of the text box to span display, switch the confirmation button to the Modify button
$ (' input[value= ' confirmation "]"). Click (function () {
$ ("input[value= ' confirms ']:eq (" + $i + ")"). Hide (). Prev (). Show ();
var $zhi =$ (". X:eq (" + $i + ")"). Val ();
$ ("Span:eq (" + $i + ")"). Text ($zhi);
$ ("table"). Find (". X:eq (" + $i + ")"). Hide ();
$ ("Span:eq (" + $i + ")"). Show ();
})
Adhere to the record of their daily learning 650) this.width=650; "src=" Http://img.baidu.com/hi/face/i_f13.gif "alt=" I_f13.gif "/>
(There will always be solutions to problems in the world, but we still face a variety of problems.) Because unless we really try to solve it, we never know which method works. )
JavaScript changes the number of items in the list of cases