2013-07-31 2 views
0

나는 함께 쓰고있는 설문지의 일부로 선택 상자에 바인딩 된 jQuery 슬라이더를 구현하려고합니다. 그러나, 나는 을 잡았습니다. Chrome에서 알려지지 않은 SyntaxError예상 됨 ')'IE에서 오류가 발생했습니다.jQuery UI 오류 - Uncaught SyntaxError : 예기치 않은 식별자

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js" type="text/javascript"></script> 
<script type="text/javascript"> 
    $(function() { 
    var select = $(".minbeds"); 
    var slider = $("<div id="slider"></div>").insertAfter(select).slider({ 
     min: 1, 
     max: 4, 
     range: "min", 
     value: select[ 0 ].selectedIndex + 1, 
     slide: function(event, ui) { 
     select[ 0 ].selectedIndex = ui.value - 1; 
     } 
    }); 

    $(".minbeds").change(function() { 
     slider.slider("value", this.selectedIndex + 1); 
    }); 
    }); 
</script> 

만 나는 코드로했습니다 달라 나는 #를 변경 한 것으로되어 다음과 jQuery를 UI 사이트에서 바로 복사 here을 발견이기 때문에 내가 사용

JQuery와는 minbeds에서 ID와 클래스 (.minbeds)에 ID.

<select class="minbeds"> 
     <option>1</option> 
     <option>2</option> 
     <option>3</option> 
     <option>4</option> 
    </select> 

이제, 코드 내 로컬 컴퓨터에 오류없이 잘 작동하는 것 같다,하지만 최대한 빨리이 CMS에 넣어, 나는이 catch되지 않은 얻을 다음과 같이

html로는 구문 에러 : 예기치 않은 식별자 (크롬) 다음 줄 사이 오류 :

var slider = $("<div id="slider"></div>").insertAfter(select).slider({ 

min: 1, 
IE9에서3210

, 내가 얻을 예상 ')' 별표가 여기에 표시 여기서

var slider = $("<div id="*slider"></div>").insertAfter(select).slider({ 

사람이 이런 일이 될 수있는 이유는 어떤 생각을 가지고 있습니까? 오류 범위를 좁힐 수있는 방법에 대한 의견이 있으십니까? 나는 JSLint를 사용해 보았지만 제대로 사용하는 방법을 모른다. 도움이된다면 여기

는 CMS의 전체 소스 코드입니다

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head id="head"><title> 
test | Gael Ltd 
</title><meta charset="UTF-8" /> 
<link href="/CMSPages/GetCSS.aspx?stylesheetname=GaelCorporate" type="text/css" rel="stylesheet" /> 
<link href="/App_Themes/Default/DesignMode.css" type="text/css" rel="stylesheet" /> 
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js" type="text/javascript"></script> 
<script type="text/javascript"> 
    $(function() { 

    var select = $(".minbeds"); 
    var slider = $("<div id="slider"></div>").insertAfter(select).slider({ 
     min: 1, 
     max: 4, 
     range: "min", 
     value: select[ 0 ].selectedIndex + 1, 
     slide: function(event, ui) { 
     select[ 0 ].selectedIndex = ui.value - 1; 
     } 
    }); 
    $(".minbeds").change(function() { 
     slider.slider("value", this.selectedIndex + 1); 
    }); 
    }); 
</script> 
<link href="/favicon.ico" type="image/x-icon" rel="shortcut icon" /> 
<link href="/favicon.ico" type="image/x-icon" rel="icon" /> 
<link href="/App_Themes/GaelCorporate/site_superfish.css" type="text/css" rel="stylesheet" /> 
<link href="/App_Themes/GaelCorporate/superfish.css" type="text/css" rel="stylesheet" /> 
</head> 

<body class="LTR IE IE9 ENGB ContentBody"> 
<form method="post" action="/test-folder/test.aspx" id="form"> 

<div class="aspNetHidden"> 
    <input type="hidden" name="manScript_HiddenField" id="manScript_HiddenField" value="" /> 
    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /> 
    <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /> 
</div> 

<script type="text/javascript"> 
//<![CDATA[ 
    var theForm = document.forms['form']; 
    if (!theForm) { 
     theForm = document.form; 
    } 
function __doPostBack(eventTarget, eventArgument) { 
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) { 
     theForm.__EVENTTARGET.value = eventTarget; 
     theForm.__EVENTARGUMENT.value = eventArgument; 
     theForm.submit(); 
    } 
} 
//]]> 
</script> 


<script src="/WebResource.axd?d=jPoMVS0EaQHOPmIi_xm2HU7yLiOSI9SwD_nAvxdPGg3slCV5HIxf7PSCa8BfM4b35NfjJ4LD1KDvV9zGMhi-uyAc4R1j13kmLSk37dPSwRA1&amp;t=635080272185083230" type="text/javascript"></script> 

<input type="hidden" name="lng" id="lng" value="en-GB" /><div> 
<input type="hidden" name="vmode" id="vmode" value="2" /> 
</div> 

<script src="/CMSPages/GetResource.ashx?scriptfile=%7e%2fCMSScripts%2fcmsedit.js" type="text/javascript"></script> 
<script src="/ScriptResource.axd?d=qITU4oF4GWOpdURxveOn4klAk_JXip46ZHYKRqOUaPkNBV9OLAT0zMmPuZjF0ltSZKQlH5lCAk6I-L0CB4BfF84f5lbs5uiDmHRHcZEufPBw7X-M84RuYSjEXgjwE-gx0&amp;t=34d147fd" type="text/javascript"></script> 
<script src="/ScriptResource.axd?d=05xl_ew97J9D2HSa4Uccwf9-hvRXKd018osO5VbhpBA71UbuP-EbmT7rx4i0SCEzVoF8fX63gNR8y-mVT88Ca0QEYuqmsHW4GGpDjGvljtfyIoQXInytcQQGxUI7XAD5x4baeNOY1cVoynUnafwICw2&amp;t=34d147fd" type="text/javascript"></script> 

<div class="aspNetHidden"> 
<input type="hidden" name="__SCROLLPOSITIONX" id="__SCROLLPOSITIONX" value="0" /> 
<input type="hidden" name="__SCROLLPOSITIONY" id="__SCROLLPOSITIONY" value="0" /> 
</div> 

<script type="text/javascript"> 
//<![CDATA[ 
    Sys.WebForms.PageRequestManager._initialize('manScript', 'form', [], [], [], 90, ''); 
//]]> 
</script> 

<div id="m" style="background:none;"> 
<div id="CMSHeaderDiv"> 
    <div id="m_PageManagerInfoContainer" class="PageManagerInfoContainer"> 
     <!-- --><div id="m_pnlPreviewInfo" class="PageManagerPreviewInfo"> 
      <span class="PreviewInfo">This is a preview mode of document <strong>test</strong>.</span><a class="PreviewInfoLink" href="javascript:__doPostBack(&#39;m$ctl02&#39;,&#39;&#39;)">Close</a><span class="PreviewInfo">the preview mode.</span> 
      </div> 
    </div> 

<script type="text/javascript"> 
    //<![CDATA[ 
    if ((parent != null) && (parent.IsCMSDesk)) { infoElem = document.getElementById('m_pnlPreviewInfo'); if (infoElem) {if (infoElem.style) { infoElem.style.display = 'none'; } else { infoElem.display = 'none'; } }} 
//]]> 
</script><!-- --> 
</div> 
</div> 

<div id="pagewrapper"> 
    <!-- vertical_menu div start --> 
<div id="vertical_menu"> 


</div><!-- vertical_menu div end --> 

<!-- content_container div start --> 
<div id="content_container"> 
<div id="zoneContent"> 
    <div id="p_lt_zoneContent_BizForm_viewBiz"> 
<div id="p_lt_zoneContent_BizForm_viewBiz_ctl00"> 
    <div id="p_lt_zoneContent_BizForm_viewBiz_ctl00_pnlForm" class="FormPanel" onkeypress="javascript:return WebForm_FireDefaultButton(event, &#39;p_lt_zoneContent_BizForm_viewBiz_ctl00_btnOK&#39;)"> 
     <table class="EditingFormTable"><tr><td class="EditingFormLabelCell"><label id="p_lt_zoneContent_BizForm_viewBiz_ctl00_select_lb" class="EditingFormLabel" for="p_lt_zoneContent_BizForm_viewBiz_ctl00_select_dropDownList">select field</label></td><td class="EditingFormValueCell"><div class="EditingFormControlNestedControl"> 

<select name="p$lt$zoneContent$BizForm$viewBiz$ctl00$select$dropDownList" id="p_lt_zoneContent_BizForm_viewBiz_ctl00_select_dropDownList" class="minbeds"> 
       <option value="1">1</option> 
       <option value="2">2</option> 
       <option value="3">3</option> 
       <option value="4">4</option> 
</select> 

</div></td></tr><tr> 

<td class="EditingFormButtonLeftCell"></td> 
<td class="EditingFormButtonCell"> 
    <input type="submit" name="p$lt$zoneContent$BizForm$viewBiz$ctl00$btnOK" value="OK" id="p_lt_zoneContent_BizForm_viewBiz_ctl00_btnOK" class="FormButton" /> 
    </td></tr></table> 
    </div> 
</div> 
</div> 

<select name="minbeds" class="selectInput"> 
    <option>1</option> 
    <option>2</option> 
    <option>3</option> 
    <option>4</option> 
</select> 
</div> 

<div class="bottomWebParts"></div> 

</div> 
<!-- content_container div end --> 

<!-- primary webparts div start --> 
<div id="primary_webparts"></div> 

<!-- primary webparts div end --> 
</div> 

<script type="text/javascript"> 
//<![CDATA[ 
    (function() {var fn = function() {$get("manScript_HiddenField").value = '';Sys.Application.remove_init(fn);};Sys.Application.add_init(fn);})();//]]> 
</script> 

<script type="text/javascript"> 
    //<![CDATA[ 
    InitializePage(); 
    //]]> 
</script> 

<script type="text/javascript"> 
    //<![CDATA[ 
    theForm.oldSubmit = theForm.submit; 
    theForm.submit = WebForm_SaveScrollPositionSubmit; 

    theForm.oldOnSubmit = theForm.onsubmit; 
    theForm.onsubmit = WebForm_SaveScrollPositionOnSubmit; 
    //]]> 
</script> 

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTYwODg0MzQ2Ng9kFgICARBkZBYCAgMPZBYCZg9kFgJmD2QWAgIDD2QWAmYPZBYCZg8PFgIeCEZvcm1Nb2RlCyl1Q01TLkZvcm1FbmdpbmUuRm9ybU1vZGVFbnVtLCBDTVMuRm9ybUVuZ2luZSwgVmVyc2lvbj02LjAuNDcxMy4yNzkyNiwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj04MzRiMTJhMjU4ZjIxM2Y5AGQWAgICD2QWAmYPZBYEAgEPDxYCHgdWaXNpYmxlaGQWAgIBDw8WBB4IQ3NzQ2xhc3MFH0VkaXRpbmdGb3JtQ29udHJvbE5lc3RlZENvbnRyb2weBF8hU0ICAmQWAmYPZBYCZg8PFgQfAgUKTGFiZWxGaWVsZB8DAgJkZAIHD2QWAgIBDw8WBB8CBR9FZGl0aW5nRm9ybUNvbnRyb2xOZXN0ZWRDb250cm9sHwMCAmQWAmYPDxYCHwJkZBYCZg8QDxYEHwIFB21pbmJlZHMfAwICZA8WBGYCAQICAgMWBBAFATEFATFnEAUBMgUBMmcQBQEzBQEzZxAFATQFATRnZGRkpyri0ouEXB8y3l0reZFw/5xfESlKtjr/PsCd4HT+bG4=" /> 
<script type="text/javascript"> 
    //<![CDATA[ 
    if (window.WebForm_InitCallback) { 
    __theFormPostData = ''; 
    __theFormPostCollection = new Array(); 
    window.WebForm_InitCallback(); 
    } 
    //]]> 
</script> 
</form> 

</body> 
</html> 

답변

1

이이 일을

var slider = $('<div id="slider"></div>').insertAfter(select).slider({ 
+0

, 감사하십시오! 초기 코드가 온라인이 아닌 내 로컬 컴퓨터에서 작동하는 이유는 무엇입니까? – fnkymnky

+0

정확하게는 아니지만 문자열 안에 문자열이있을 때마다이 ' ""'처럼 넣는 것이 더 좋습니다. 브라우저는 구문 분석 오류를 발생시키지 않습니다 ... http://www.w3.org/TR/css3- 값/# 구성 요소 유형 – Akki619

2

var slider = $("<div id='*slider'></div>").insertAfter(select).slider({ 

같은 시도하거나 직접이

var slider = $("div #slider").insertAfter(select).slider({ 

같이 할 수있는 나는 당신을 생각 select을 작은 따옴표 나 큰 따옴표로 묶어야합니다.

관련 문제