You shouldn't escape hyphens, they are very common in classnames and
not special characters in a selector. But your cellWidth object throws
syntax error, this is how it should look like:

 var cellWidth = {
    searchUser: [80, 110, 145, 70, 100, 100, 236],
    searchAcct: [80, 130, 80, 80, 80, 190, 201],
    searchCntr: [75, 120, 86, 86, 86, 86, 110, 80],
   //you should quote reserved words and special characters:
    "acct-his": [200, 303, 203]  //IE doesn't like the comma here
   };

If you still get the error please provide some code or a test page.

On Jan 10, 2:52 am, roxstyle <resut...@gmail.com> wrote:
> I am having no luck with non-standard characters in class names, used
> in a function
>
> I am using this is a wonderful technique via Karl, that allows
> children to inherit their parent td width.
>
> $(document).ready(function() {
>    var cellWidth = {
>     searchUser: [80, 110, 145, 70, 100, 100, 236],
>     searchAcct: [80, 130, 80, 80, 80, 190, 201],
>     searchCntr: [75, 120, 86, 86, 86, 86, 110, 80],
>     acct-his: [200, 303, 203],
>    };
>
>    $.each(cellWidth, function(key, val) {
>      for (var i=0, cl= val.length; i<cl; i++) {
>        $('.' + key + ' tbody td:nth-child(' + (i+1) + ')').width(val
> [i])
>          .children().css({overflow: 'hidden'}).width(val[i]);
>      };
>    });
>
> });
>
> My problem is with class names with non-standard characters (in my
> case hyphens). Jquery doesn't recognize these. I tested the techniques
> on:http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_...
>
> so in line 8 below, i tried things like:
> acct\\-his
> acct-[his]
> $('.' + key.replace(/-/g,"\\-") + ' tbody td:nth-child(' + (i+1) +
> ')').width(val[i])
>
> if any one can point me to other solutions, i would be very grateful.

Reply via email to