HTML and CSS Reference
In-Depth Information
case "C":
$("#GridView1 tr a[href *= 'products/']").parent().css("display", "none");
$("#GridView1 tr a[href |= 'Paper']").parent().css("display", "none");
$("#GridView1 tr a[href $= '']").parent().css("display", "block");
Selecting Form Elements
Form selectors let you select HTML <form> elements based on their type (text box, check box, radio button,
and so on) or their status (selected, checked, or disabled). Table 2-5 lists the various form selectors
Table 2-5. Form Selectors
Elements Selected
<input> elements of type button , and <button> elements
<input> elements of type checkbox
Check boxes and radio buttons that are checked
Elements that are disabled
Elements that are enabled
<input> elements of type ile
<input> elements of type image
Elements of type <input> , <textarea> , <select> , and <button>
<input> elements of type password
<input> elements of type radio
<input> elements of type reset
Options of a <select> element that are selected
<input> elements of type submit
<input> elements of type text
Listing 2-9 shows some of the selectors mentioned in Table 2-5.
Listing 2-9. Basic Usage Syntax of Form Selectors
$(document).ready(function () {
$("#form1 :text").attr("disabled", "disabled");
$("#form1 :checkbox").attr("checked", "checked");
$("#Button1").click(function () {
alert($("#form1 input[type='checkbox']:checked").length + " checkboxes are checked.");
alert($("#Select1 option:selected").length + " options are selected.");
The first form selector in Listing 2-9 selects all text boxes and disables them by adding the disabled
attribute. The jQuery attr() function is used to set attribute values of an element. The first parameter of
attr() is the name of the attribute, and the second parameter is its value. In this case, the disabled
attribute is set to a value of disabled so as to disable the text boxes.
Search WWH ::

Custom Search