JavaScript changes the number of items in the list of cases

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.