Adding "step" attribute to input field

Adding "step" attribute to input field

Hi,

I'm trying to add the "step" attribute to a already generated html number input field.

  1.     jQuery(document).ready(function($){
  2.       $( "#fieldname" ).attr( "step", "0.1" );
  3.     });

But for some reason its not working.

This is what the fields looks like on page load
  1. <input id="fieldname" name="fieldname" class="class" type="number" value="">
And i would like to change it to:

  1. <input id="fieldname" name="fieldname" class="class" type="number" step="0.1" value="">
I'm also using Wordpress.