TAILIEUCHUNG - jQuery in Action phần 5

Tham khảo tài liệu 'jquery in action phần 5', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 80 CHAPTER 3 Bringing pages to life with jQuery checked or unchecked states of check boxes and radio buttons and will return the value of check boxes or radio buttons as defined by their value attribute regardless of whether they are checked or not. For radio buttons the power of jQuery selectors combined with the val method saves the day. Consider a form with a radio group a set of radio buttons with the same name named radioGroup and the following expression name radioGroup checked .val This expression returns the value of the single checked radio button or undefined if none is checked . That s a lot easier than looping through the buttons looking for the checked element isn t it Since val only considers the first element in a wrapped set it s not as useful for check box groups where more than one control might be checked. If we want to obtain the values with which the controls would be submitted through a form submission we ll be much better off using the serialized command which we ll see in chapter 8 or the official Form Plugin. Another common operation we ll perform is to set the value of a form element. The val command is also used for this purpose by supplying a value. Its syntax is as follows Command syntax val val value Sets the passed value as the value of all matched form elements Parameters value String A string that s set as the value property of each form element in the wrapped set Returns The wrapped set Like the get variant of this command this function has its limitations. It can t set multiple values into a multiselect list for example. This is the reason that much more robust functionality is available in the Form Plugin. In addition to lifting the limitations mentioned so far it s capable of such operations as retrieving an array of values for check box groups serializing the elements in the wrapped set clearing fields and even converting a DOM form into a format suitable for use with Ajax. Summary 81 Another way that the val method can be used

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.