Forum Moderators: open

Message Too Old, No Replies

Missing ) inside jQuery

         

toplisek

2:42 pm on Mar 16, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have set CSS selector to be read by all browser like:
selector = {
init: function() {
jQuery(".myboxes [class*="mycolumns-"] :nth-child(3n+3)").css("margin-right", 0);
}
}
There is an error inside validation like
Error: SyntaxError: missing ) after argument list

How to avoid/fix this error?

Fotiman

3:13 pm on Mar 16, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You have double quotes within your double quoted string. Try this:
jQuery('.myboxes [class*="mycolumns-"] :nth-child(3n+3)').css("margin-right", 0);

toplisek

4:50 pm on Mar 16, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have tested in the mean time you posted and done as you quoted. It is interesting that [class*="mycolumns-"] is not detected but it works just .myboxes :...

It seems that > sign works for all elements inside (directly) .myboxes but [class*="mycolumns-"] can not detect class inside jQuery due to class added to all elements. As it is secondary level...

Fotiman

6:18 pm on Mar 16, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm not sure I understand what you're saying, but the following works for me:

<div class="myboxes">
<div class="a">
<div class="mycolumns-x">
<div>X</div>
<div>Y</div>
<div>Z</div>
</div>
</div>
</div>


// Makes the Z red
$('.myboxes [class*="mycolumns-"] :nth-child(3n+3)').css("color", "red");

toplisek

7:32 pm on Mar 16, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Strange. I'm not sure either.