0

I am using livequery in order to detect created elements and apply some css.

It works, but I have a problem with certain selectors.

HTML:

<p id="Test:SomeElement.Id">TEST3</p>

JS:

$("body").livequery("#Test\:SomeElement\.Id" , function() { 
$(this).css('color', 'red');
})

The example above will generate this error:

Syntax error, unrecognized expression: unsupported pseudo: SomeElement

enter image description here

Looks like its a bug in livequery since jquery won't fail with this selector.

This is the JS fiddle http://jsfiddle.net/20f05p33/1/ Please scroll the js frame to the bottom in order to skip the livequery library.

Milos
  • 2,927
  • 1
  • 15
  • 27

2 Answers2

1

User \\ instead of \

$("body").livequery("#Test\\:SomeElement\\.Id" , function() { 
  $(this).css('color', 'red');
})

Or

$("body").livequery('p[id="Test:SomeElement.Id"]' , function() { 
      $(this).css('color', 'red');
})
Bharat
  • 2,441
  • 3
  • 24
  • 36
0

Check updated fiddle: jsfiddle.net/20f05p33/2/

$(document).ready(function () {
  $( "#btn" ).click(function() {
    $( "#nav" ).append( '<p class="warning">TEST2</p>' );
    $( "#nav" ).append( '<p id="Test:SomeElement.Id">TEST3</p>' );
  }); 
});

var myStringArray = ['.warning', '[id="Test:SomeElement.Id"]'];

        try {
            $("body").livequery(myStringArray.join() , function() { 
                $(this).css('color', 'red');
            })
        }
        catch(err) {
            console.log(err.message);
            alert(err.message);
        }
Bharatsing Parmar
  • 2,435
  • 1
  • 9
  • 18