Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy is this jquery selector not selecting textarea?
    primarykey
    data
    text
    <p>in the following, I am using filter('input:text,textarea') to set input fields as read only, (and make them opaque). However, this selector is selecting only the text inputs, and not the textarea. What am I doing wrong?</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;setReadOnly() Test&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="../styles/core.css"&gt; &lt;link rel="stylesheet" type="text/css" href="test.setReadOnly.css"&gt; &lt;script type="text/javascript" src="../scripts/jquery-1.4.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../scripts/jqia2.support.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; (function($){ $.fn.setReadOnly = function(readonly) { return this.filter('input:text,textarea') .attr('readOnly',readonly) .css('opacity', readonly ? 0.5 : 1.0) .end(); }; })(jQuery); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(function(){ $('#sameAddressControl').click(function(){ var same = this.checked; $('#billAddress').val(same ? $('#shipAddress').val():''); $('#billCity').val(same ? $('#shipCity').val():''); $('#billState').val(same ? $('#shipState').val():''); $('#billZip').val(same ? $('#shipZip').val():''); $('#bill_random_field').val(same ? $('#ship_random_field').val():''); $('#billingAddress input').setReadOnly(same); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div data-module="Test setReadOnly()"&gt; &lt;form name="testForm"&gt; &lt;div&gt; &lt;label&gt;First name:&lt;/label&gt; &lt;input type="text" name="firstName" id="firstName"/&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;Last name:&lt;/label&gt; &lt;input type="text" name="lastName" id="lastName"/&gt; &lt;/div&gt; &lt;div id="shippingAddress"&gt; &lt;h2&gt;Shipping address&lt;/h2&gt; &lt;div&gt; &lt;label&gt;Street address:&lt;/label&gt; &lt;input type="text" name="shipAddress" id="shipAddress"/&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;City, state, zip, random_field:&lt;/label&gt; &lt;input type="text" name="shipCity" id="shipCity"/&gt; &lt;input type="text" name="shipState" id="shipState"/&gt; &lt;input type="text" name="shipZip" id="shipZip"/&gt; &lt;textarea name="random_field" rows="2" cols="20" id="ship_random_field"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="billingAddress"&gt; &lt;h2&gt;Billing address&lt;/h2&gt; &lt;div&gt; &lt;input type="checkbox" id="sameAddressControl"/&gt; Billing address is same as shipping address &lt;/div&gt; &lt;div&gt; &lt;label&gt;Street address:&lt;/label&gt; &lt;input type="text" name="billAddress" id="billAddress"/&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;City, state, zip, random_field:&lt;/label&gt; &lt;input type="text" name="billCity" id="billCity"/&gt; &lt;input type="text" name="billState" id="billState"/&gt; &lt;input type="text" name="billZip" id="billZip"/&gt; &lt;textarea name="random_field" rows="2" cols="20" id="bill_random_field"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload