# 问题内容:

In the following code var roomName = $(this).prev('.room_name').val(); works fine but var length =$(this).prev('.room_length').val(); doesn’t. Why is this, both lines of code seem almost identical in theory albeit they are referencing a different class of input.

jQuery;

// check for dimension unit

$( "#manage_property_rooms" ).submit(function( event ) {$('.dimension_unit').not("#room_details_0 .dimension_unit").each(function() {

var dim_unit = $(this).val(); var roomName =$(this).prev('.room_name').val();
var length = $(this).prev('.room_length').val(); var width =$(this).prev('.room_width').val();

if ( (length > 0 || width > 0) && dim_unit=='' ) {