2010-11-09 64 views
4

好吧我有css排序:與jquery樣式輸入

現在樣式輸入框(但這不是工作)任何建議。認爲我的js搞砸了。 html元素:

<input name="latLng" class="latLng" id="latLng2" type="text" disabled /> 

的JS:

<script type="text/javascript"> 
jQuery(document).ready(function(){ 
    jQuery('input.latLng').locationPicker({ 
    width: "500px", 
    height: "20px", 
    backgroundColor: '#fff', 
    border: '1px solid #ccc', 
    borderRadius: 10, 
    padding: 10 
    }); 
}); 
</script> 

我要去哪裏錯了,請。

+0

爲了格式,請選擇您的代碼並點擊頂部的'101010'按鈕,或者手動將其縮進4個空格:) – 2010-11-09 23:08:53

+0

或者選擇代碼並按Ctrl + K' – 2010-11-09 23:15:39

+0

或在代碼段周圍鍵入反引號(')以執行內聯代碼。 – Ender 2010-11-10 00:15:16

回答

2

要設置樣式,使用.css()的元素的造型,並分別打電話給你的插件,像這樣:

jQuery(document).ready(function(){ 
    jQuery('input.latLng').css({ 
    width: "500px", 
    height: "20px", 
    backgroundColor: '#fff', 
    border: '1px solid #ccc', 
    borderRadius: 10, 
    padding: 10 
    }).locationPicker(); 
}); 

或者短一點:

jQuery(function($){ 
    $('input.latLng').css({ 
     width: 500, 
     height: 20, 
     backgroundColor: '#fff', 
     border: '1px solid #ccc', 
     borderRadius: 10, 
     padding: 10 
    }).locationPicker(); 
}); 
+0

感謝尼克,將嘗試(我試圖得到這樣的掛) – 422 2010-11-09 23:09:56

+0

好了現在的代碼是:

所有似乎工作正常,只是圓角沒有真正顯示(選擇3px匹配其他表單元素) – 422 2010-11-09 23:20:11