0

I have a form input that looks like this:

<input type="text" name="params[well]" id="params_well" value="#f8f8f8" placeholder="#rrggbb" class="minicolors minicolors-input" data-position="right" data-control="hue" size="7" maxlength="7">

and javascript like this:

var params_well = $("#params_well").val();

and getting this error:

Uncaught TypeError: Cannot call method 'val' of null

I really cant proceed with anything else till i figure this out

TEN Design
  • 717
  • 3
  • 13
  • 31

2 Answers2

0

Assuming the jQuery is integrated correctly, you probably trying to access before element is being added to DOM. Your code is working fine.

Live Demo

$(document).ready(function(){
  var params_well = $("#params_well").val();
});

You can include jQuery using script tag, also worth going through this post.

<script src="http://code.jquery.com/jquery-latest.min.js"
  type="text/javascript"></script>
Community
  • 1
  • 1
Adil
  • 146,340
  • 25
  • 209
  • 204
0

Try this

$(document).ready(function(){
  var params_well = $("#params_well").val();
});

Or put this on bottom of your page

var params_well = $("#params_well").val();