Question

When I use below notation with '>' in line

$('#tablesorter > tbody')

in code

var message;
myService.getUsers({ callback : function(str) { 
    message= jQuery.parseJSON(str);
}}); 

$.each(message, function() {

    $('#tablesorter > tbody').append(
    '<tr><td>' + this.name
    + '</td><td>' + this.surname
    + '</td>' + '</tr>');
});

Note: myservice is a dwr service, don't know if it is related

I have error in chrome console

Uncaught Error: Syntax error, unrecognized expression: &gt;

&gt; means >

When I deleted the > the error disappears but it does not work as expected

Was it helpful?

Solution

Wherever you're outputting your code, it's getting transformed to automatically escape. Perhaps you have a templating language in between.

You need to either store all of your javascript code in a separate file (the best solution), or find a way with your pages (JSP?) to disable output escaping.

OTHER TIPS

the greater than > symbol is used in CSS selectors (which jQuery selectors are based on) to indicate a "direct descendent".

Documentation

The code you posted works fine, the > symbols in there would not cause any errors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top