2014-06-11 2 views
0

IF 문을 기반으로 일부 텍스트를 삽입하는 데 사용하는 일부 jquery가 있습니다.이 기능은 완벽하게 작동하지만 지금은이 텍스트에 새 클래스를 추가하여 스타일을 적용해야합니다. 이것은 아무것도 렌더링하지 않습니다.Jquery : 텍스트에 html 추가

기존 및 작동 스크립트. 내가 한과 파산 무엇

 $(document).ready(function(){ 
     if($('.productdetail').length){ 
     }else{ 
     document.getElementById('listwrapper').innerHTML = "Sorry! Your search found no products, please adjust your filters. If you need help call (02) 9620 2424." 
     } 
     }); 

:

 $(document).ready(function(){ 
     if($('.productdetail').length){ 
     }else{ 
     document.getElementById('listwrapper').innerHTML = "<span class='sorry'>Sorry! Your search found no products, please adjust your filters. If you need help call (02) 9620 2424.</span>" 
     } 
     }); 

어떤 조언이나 도움이 좋지 않을까! 이 같은 JQuery와의

+1

'$ ('#의 listwrapper'). html로 ("<스팬 클래스 = '죄송합니다'> 죄송합니다! 귀하의 검색이 제품이, 필터를 조정하지하시기 바랍니다 발견했다. 당신은 도움의 전화 (02) 9620 2424이 필요합니다. ")'? – MLeFevre

+1

코드가 작동합니다 (http://jsfiddle.net/MJ8Dc/). '.sorry' 클래스'display/visibility'가'none'으로 설정되어 있지 않은지 확인해야합니다. –

+0

'listwrapper' 란 무엇입니까? – Abhitalks

답변

0

사용 .html()

$(document).ready(function(){ 
     if($('.productdetail').length){ 
     } 
     else{ 
       $('#listwrapper').html("<span class='sorry'>Sorry! Your search found no products, please adjust your filters. If you need help call (02) 9620 2424.</span>"); 
     } 
}); 
-2

사용.

$(document).ready(function(){ 
    if($('.productdetail').length){ 
    }else{ 
    document.getElementById('listwrapper').html("<span class='sorry'>Sorry! Your search found no products, please adjust your filters. If you need help call (02) 9620 2424.</span>");} 
    });