Jquery val() doens't work on hidden fields
I have a weird problem with some jQuery code for a project I'm working on. 开发者_C百科I have to make a backend system, but it has to work in IE7 for the customer care department of the company.
I have a image plugin in the system where you can recrop te images. When you do that, this piece of code will be generated
<input id="imagewidth_large" type="hidden" value="640" name="imagewidth_large">
<input id="imageheight_large" type="hidden" value="360" name="imageheight_large">
<input id="imagewidth_xlarge" type="hidden" value="640" name="imagewidth_xlarge">
<input id="imageheight_xlarge" type="hidden" value="270" name="imageheight_xlarge">
<input id="imagewidth_list" type="hidden" value="360" name="imagewidth_list">
<input id="imageheight_list" type="hidden" value="270" name="imageheight_list">
<input id="imagewidth_grid" type="hidden" value="270" name="imagewidth_grid">
<input id="imageheight_grid" type="hidden" value="270" name="imageheight_grid">
<input id="imagewidth_grid_wide" type="hidden" value="230" name="imagewidth_grid_wide">
<input id="imageheight_grid_wide" type="hidden" value="135" name="imageheight_grid_wide">
<input id="orgwidth" type="hidden" value="1224" name="orgwidth">
<input id="orgheight" type="hidden" value="1632" name="orgheight">
<input id="orgpath" type="hidden" value="../../uploads/images/tmp/4e89d17443230.jpg" name="orgpath">
<input id="targetfile" type="hidden" value="../../uploads/images/tmp/4e89d17443230.jpg" name="targetfile">
<input id="crop_width" type="hidden" value="1224" name="crop_width">
<input id="crop_height" type="hidden" value="688.5" name="crop_height">
<input id="crop_rat" type="hidden" value="0.5228758169934641" name="crop_rat">
<input id="crop_x" type="hidden" value="0" name="crop_x">
<input id="crop_y" type="hidden" value="0" name="crop_y">
<input id="source" type="hidden" value="other" name="source">
<input id="croppedimage" type="hidden" value="" name="croppedimage">
This code are some reference fields (the plugin is an extended version of a smaller cropper)
The problem I have is that in my code you can press the recrop button that will open the recropper and generate some code. In this code he calls and sets values of these input fields.
The problem is that I can't set of read values of the fields.
$("#imagewidth_large").val();
This returns undefined
$("#imagewidth_large").val(500);
This doens't do anything.
Thanks
Your HTML and jQuery code should be able to read the val(). Check it out here:
http://jsfiddle.net/hZJVj/
精彩评论