422
422

Reputation: 5770

Styling input with jquery

Ok I have the css sorted:

Now to style the input box ( but this isnt working ) any suggestions. Think my js is messed 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.

Upvotes: 4

Views: 1067

Answers (1)

Nick Craver
Nick Craver

Reputation: 630379

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();
});

Upvotes: 2

Related Questions