使用jquery设置样式输入

时间:2010-11-09 23:03:40

标签: jquery

好的我已经将css排序了:

现在设置输入框的样式(但这不起作用)任何建议。认为我的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>

我在哪里出错。

1 个答案:

答案 0 :(得分: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();
});