2017-01-18 4 views
0

생성 된 요소를 감지하고 일부 CSS를 적용하기 위해 livequery을 사용하고 있습니다.라이브 쿼리가 지원되지 않는 유사 문제

작동하지만 특정 선택기에 문제가 있습니다.

HTML :

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

JS :

Syntax error, unrecognized expression: unsupported pseudo: SomeElement

enter image description here

가 livequ에서의 버그 같은데 다음 예는 상술 한 오류를 생성

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

이 선택기로 jquery가 실패하지 않으므로 ery가됩니다.

이것은 JS 바이올린입니다. http://jsfiddle.net/20f05p33/1/ 라이브 쿼리 라이브러리를 건너 뛰려면 js 프레임을 맨 아래로 스크롤하십시오.

답변

1

사용자 \\ 대신 \

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

또는

$("body").livequery('p[id="Test:SomeElement.Id"]' , function() { 
     $(this).css('color', 'red'); 
}) 
0

확인 업데이트 바이올린의 : 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); 
     } 
관련 문제