Problem of symbol

$(‘[name^=strCustTerr]’)

what does this ^= means ? I don’t think its “not”…what is it ?

if(strCustTerr.size() === strCustTerr.filter(‘:checked’).size()){

what is this symbol : …what it means when we do :checked ?

Those are standard CSS syntax.

[http://api.jquery.com/attribute-starts-with-selector/"]This page](http://www.sitepoint.com/forums/[QUOTE) details all the selectors and there use:

Selects elements that have the specified attribute with a value beginning exactly with a given string.

This selector can be useful for identifying elements in pages produced by server-side frameworks that produce HTML with systematic element IDs. However it will be slower than using a class selector so leverage classes, if you can, to group like elements.

I have tried testing ^= with the following code, click event only got applied to chk1 as that is the exact match:

html


<input type="checkbox" name="chk1" value="1">1<br>
<input type="checkbox" name="chk2" value="2">2

jquery


$(document).ready(function(){

        $('input[name ^= "chk1"]').click(function(){
            alert($(this).val());
        });
    });

Any thing that starts with a : is a selector, these are used for “matching a set of elements in a document”.

In the example below, click only gets attached to chk2.

html


<input type="checkbox" name="chk1" value="1" checked>1<br>
<input type="checkbox" name="chk2" value="2">2

jquery


$(document).ready(function(){

        $('input:not(:checked)').click(function(){
            alert($(this).val());
            
        });
    });

Take a look at the following page, it has detailed information.
http://api.jquery.com/category/selectors/

I have modified the above code and used :not and :checked inside the if statement. It always alerts ‘checked’ even when the check box is not checked. .attr(‘checked’) on the other hand behaves properly. A jQuery guru will need to explain this behavior.


$(document).ready(function(){

        $('input[type="checkbox"]').click(function(){
            
            //*** this always results in checked
            if($(this)+(':not(:checked)'))
                alert('checked');

            else
                alert('not checked');
            
            //*** this outputs properly
            if($(this).attr('checked'))
                alert('checked');

            else
                alert('not checked');
            
        });
    });

Forgot to mention that those are JQuery syntax.