2011-12-24 5 views
1

페이지로드/새로 고침에 한 번 실행하려면 다음 코드를 얻으려고하고 있지만 페이지가로드되면 일단 작동 변경이 제대로 작동하지 않습니다. 내가 거기에 경고의 형식은 여기jquery 트리거가 양식의 모든 입력을 호출합니까?

$(document).ready(function(e) {   
//attach handler and call once 
    $(':input[name$=":finopt:2"]').change(function() { 
     var arg = $(this).val(); 
     $.each(screwHolderArr,function(){ 
      //alert(screwImgPath+screwColorArr[arg]); 
      $('#'+this).css("background-image", "url("+screwImgPath+screwColorArr[arg]+")") 
     }); 

    }); 

    //trigger change once 
    $(':input[name$=":finopt:2"]').trigger('change'); 
} 

의 모든 입력에 대한 모든 입력 값을 보여줍니다 던져

선택 상자에게 사전에 어떤 도움

<select name="36309:finopt:2" size="1"> 
             <option value="White Standoffs">White Standoffs</option> 
             <option value="Black Standoffs">Black Standoffs</option> 
             <option value="Silver Standoffs">Silver Standoffs</option> 
            </select> 

덕분에

답변

0

시도 :

 
$(document).ready(function(e) { 
//assign some id to your select  
//attach handler and call once 
    $("select[id='yourSelectId']").change(function() { 
     var arg = $(this).val(); 
     $.each(screwHolderArr,function(){ 
      //alert(screwImgPath+screwColorArr[arg]); 
      $('#'+this).css("background-image", "url("+screwImgPath+screwColorArr[arg]+")") 
     }); 

    }); 

    //trigger change once 
    $("select[id='yourSelectId']").trigger('change'); 
} 
+0

고마워요. 당신의 생각이 충분히 잘 작동 했어요.''input '을'select'로 바꿨고, 마침내 성공했습니다. 가능하다면 id를 추가했을 것입니다. – Natdrip

관련 문제