开发者

Styling input with jquery

开发者 https://www.devze.com 2023-01-24 20:26 出处:网络
Ok I have the css sorted: Now to style the input box ( but this isnt working ) any suggestions. Think my js is mes开发者_开发知识库sed up.

Ok I have the css sorted:

Now to style the input box ( but this isnt working ) any suggestions. Think my js is mes开发者_开发知识库sed up. The html element:

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

The 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>

Where am I going wrong please.


To set styles, use .css() for the styling of the element and call your plugin separately, like this:

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

Or, a bit shorter:

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

精彩评论

暂无评论...
验证码 换一张
取 消