Hi

My first message on this board after some weeks learning, and fighting
with, jQuery. My main question is: is there any documentation on
simple comparative operators in jQuery? I'm thinking of =, <, >, <>,
that sort of thing. I'm aware that these symbols aren't used in
jquery, so that to test equality, say, you have to use is(), but I
can't find any documentation on is() or similar. This has come to mind
because of the following simple code:

// Choosing 'Other' from the organisation type combo box displays the
'other type' field
        $("#myorgtype").change(function()
        {
                var temp = $(this).val();
                alert (temp);
                // if (temp == "Other")
                if ($(this).val().is('Other'))
                {
                        alert ('other');
                }
        });

used with a simple combo box:

<select name="myorgtype" id="myorgtype">
          <option value=""  selected="selected">Please Select</option>
          <option value="Further Education"  >Further Education</
option>
          <option value="Higher Education"  >Higher Education</option>
          <option value="Schools" >Schools</option>
          <option value="NHS">NHS</option>
          <option value="Commercial" >Commercial</option>
          <option value="Other" >Other (please specify)</option>
        </select>

Can't get much simpler. However, the comparative operation:

if ($(this).val().is("Other"))

throws the error:

$(this).val().is is not a function

whereas comparing the value of 'temp' is fine. Ok, no big, not a
problem, I'll just use the var assignment, but I would like a) to know
why is() isn't working, and b) to find documentation on comparative
operators. I've also tried $('#myorgtype option:selected"), and the
explicit element id rather than 'this', but no dice.

Cheers

Fred

PS: Although I'm a trained and long-experienced programmer and web
developer, I've found the learning curve for jQuery to be steeper than
that for Javascript, and have definitely spent longer using jQuery for
simple operations than I'd have done using bare JS. Now that I've
invested many tens of hours in jQuery I'll stick with it and I'm sure
that eventually it's pay productivity dividends, but it has been quite
a headache... :((

Reply via email to