JSP中的每行限制细胞

时间:2017-05-13 22:58:18

标签: java jsp servlets

我想在jsp页面中显示数据库中的一些产品,我用一个表来显示它们,它显示所有产品在一行中,我想限制每行的单元格数(td),例如每行5 .. 这是重新获得enter image description here

这是我使用的代码 enter image description here

感谢你

1 个答案:

答案 0 :(得分:0)

打开并关闭该行
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

	  <script>
		var css_background = 'brown';
		
		function css_func (){
			css_tag = ".result{background:" + css_background + " ; width:500px; height:400px; border:"+css_background+" solid 2px;}";
			$('style').replaceWith('<style>'+css_tag+'</style>');
		}
		$(document).ready(function(){
			css_func();
			
      //change the color with selector (It's work fine)
			$('select').change(function(){
				css_background = $(this).val();
				css_func();
			});
      
      //change the color with button
			$('button').change(function(){
				css_background = $(this).val();
				css_func();
			});
		});
	  </script>

   <body>
		<div class="container">
			<div class="left">
				<button style="background-color:red;width:50px;height:30px" class="Red" value='red'></button>
				<button style="background-color:black;width:50px;height:30px" class="Black" value='black'></button>
				<button style="background-color:blue;width:50px;height:30px" class="Blue" value='blue'></button>
				<button style="background-color:pyrple;width:50px;height:30px" class="Purple" value='purple'></button>
				<button style="background-color:brown;width:50px;height:30px" class="Brown" value='brown'></button>
        
				<select class="elem" style="width:50px;height:30px">
					<option value='red'>Red</option>
					<option value='black'>Black</option>
					<option value='blue'>Blue</option>
					<option value='purple'>Purple</option>
					<option value='brown'>Brown</option>
				</select>
			</div>
     
			<div class="right">
				<div class="result"></div>
			</div>
		</div>
   </body>

当它达到你想要的总数时迭代你的行然后突破循环