div中不需要的br标签[关闭]
Posted
技术标签:
【中文标题】div中不需要的br标签[关闭]【英文标题】:Unwanted br tag in div [closed] 【发布时间】:2013-05-31 17:01:03 【问题描述】:我正在使用 jquery ajax 在 jsp 页面中填充一些值,但它会产生不需要的 br 标记
这是我的jsp页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@page import="pojo.AppointmentDetails"%>
<%@page import="pojo.MiniProvider"%>
<%@page import="pojo.MiniFacility"%>
<%@page import="pojo.Patient"%>
<%@page import="pojo.AppoinmentTimedetails"%>
<%@page import="pojo.AppointmentTypes"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GMQ Physician Associates</title>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/style2.css" />
<![endif]-->
<!--[if !IE]> -->
<link rel="stylesheet" type="text/css" href="css/style.css" />
<!-- <![endif]-->
<link rel="stylesheet" type="text/css" href="css/jquery-ui-1.8.22.custom.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/basicnifo.js"></script>
<script type="text/javascript" src="js/datepicker2.js"></script>
<script type="text/javascript" language="javascript" src="js/scripts.js"></script>
<script src="js/jquery.validate.js"></script>
<!--<script type="text/javascript" src="js/jquery-ui-1.8.22.custom.min.js"></script>
-->
</head>
<%
AppoinmentTimedetails appoinmentTimedetails=null;
Patient patient=new Patient();
patient.setsState("");
AppointmentDetails []appointmentDetails=null;
MiniProvider [] miniProviders=null;
MiniFacility[]miniFacilities =null;
AppointmentTypes []appointmentTypes=null;
miniFacilities=(MiniFacility[])request.getAttribute("miniFacilities");
if(miniFacilities==null)
miniFacilities=new MiniFacility[1];
miniFacilities[0]=new MiniFacility();
miniFacilities[0].setiFacilityId(0);
miniFacilities[0].setsFacilityName("");
miniProviders=(MiniProvider[])request.getAttribute("miniProviders");
if(miniProviders==null)
miniProviders=new MiniProvider[1];
miniProviders[0]=new MiniProvider();
miniProviders[0].setiProviderId(0);
miniProviders[0].setsProviderName("");
appointmentDetails=(AppointmentDetails[])request.getAttribute("appointmentDetails");
if(appointmentDetails==null)
appointmentDetails=new AppointmentDetails[1];
appointmentDetails[0]=new AppointmentDetails();
appointmentDetails[0].setsStatus("");
appointmentDetails[0].setsFacilityName("");
appointmentDetails[0].setsProviderName("");
appointmentDetails[0].setsStartTime("");
appointmentTypes=(AppointmentTypes[])request.getAttribute("appointmentTypes");
if(appointmentTypes==null)
appointmentTypes=new AppointmentTypes[1];
appointmentTypes[0]=new AppointmentTypes();
appointmentTypes[0].setiAppointmentTypesId(0);
appointmentTypes[0].setsCaption("");
/*appoinmentTimedetails=(AppoinmentTimedetails)request.getAttribute("appoinmentTimedetails");
if(appoinmentTimedetails==null)
appoinmentTimedetails=new AppoinmentTimedetails();
appoinmentTimedetails.setsLocation("");
appoinmentTimedetails.setsProvider("");
appoinmentTimedetails.setsVisitType("");
*/
%>
<body>
<div id="main">
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td ><img src="images/logo.jpg" /></td>
<td ><img src="images/people.jpg" class="m1" /></td>
</tr>
<tr>
<td colspan="2"><div class="m2">
<a href="#"><div id="home" style="background:url(images/topnav-bt-bg1.png) no-repeat;" class="topnav" onMouseOver="changeBgImage('images/topnav-bt-bg2.png', 'home')" onMouseOut="changeBgImage('images/topnav-bt-bg1.png', 'home')">HOME</div></a>
<a href="#"><div id="service" style="background:url(images/topnav-bt-bg1.png) no-repeat;" class="topnav" onMouseOver="changeBgImage('images/topnav-bt-bg2.png', 'service')" onMouseOut="changeBgImage('images/topnav-bt-bg1.png', 'service')">SERVICES</div></a>
<a href="#"><div id="provider" style="background:url(images/topnav-bt-bg1.png) no-repeat;" class="topnav" onMouseOver="changeBgImage('images/topnav-bt-bg2.png', 'provider')" onMouseOut="changeBgImage('images/topnav-bt-bg1.png', 'provider')">PROVIDER</div></a>
<a href="#"><div id="register" style="background:url(images/topnav-bt-bg1.png) no-repeat;" class="topnav" onMouseOver="changeBgImage('images/topnav-bt-bg2.png', 'register')" onMouseOut="changeBgImage('images/topnav-bt-bg1.png', 'register')">REGISTRATION</div></a>
<a href="#"><div id="faq" style="background:url(images/topnav-bt-bg1.png) no-repeat;" class="topnav" onMouseOver="changeBgImage('images/topnav-bt-bg2.png', 'faq')" onMouseOut="changeBgImage('images/topnav-bt-bg1.png', 'faq')">FAQ</div></a>
<a href="#"><div id="contact" style="background:url(images/topnav-bt-bg1.png) no-repeat;" class="topnav" onMouseOver="changeBgImage('images/topnav-bt-bg2.png', 'contact')" onMouseOut="changeBgImage('images/topnav-bt-bg1.png', 'contact')">CONTACT</div></a>
</td>
</tr>
</table>
<table border="0" align="center" cellpadding="0" cellspacing="0" class="m5">
<tr>
<td valign="top" class="m3">
<div class="m3a">Quick Menu</div>
<div class="m9">
<a href="Basic_info?action=basic"><div id="basic" style="background:url(images/basic-info-bt1.png) no-repeat;" class="leftnav" onMouseOver="changeBgImage('images/basic-info-bt2.png', 'basic')" onMouseOut="changeBgImage('images/basic-info-bt1.png', 'basic')">Basic Info</div></a>
<a href="Basic_info?action=appoinments:"><div id="app" style="background:url(images/appointments-bt2.png) no-repeat;" class="leftnav">Appointments</div></a>
<a href="newMessage.jsp">
<div id="newmess" style="background:url(images/new-message-bt1.png) no-repeat;" class="leftnav" onMouseOver="changeBgImage('images/new-message-bt2.png', 'newmess')" onMouseOut="changeBgImage('images/new-message-bt1.png', 'newmess')">New Message</div></a>
<a href="Basic_info?action=inbox:"><div id="inbox" style="background:url(images/inbox-bt1.png) no-repeat;" class="leftnav" onMouseOver="changeBgImage('images/inbox-bt2.png', 'inbox')" onMouseOut="changeBgImage('images/inbox-bt1.png', 'inbox')">Inbox</div></a>
<a href="Basic_info?action=outbox:"><div id="outbox" style="background:url(images/outbox-bt1.png) no-repeat;" class="leftnav" onMouseOver="changeBgImage('images/outbox-bt2.png', 'outbox')" onMouseOut="changeBgImage('images/outbox-bt1.png', 'outbox')">Outbox</div></a>
<a href="Basic_info?action=health-summary:"><div id="health" style="background:url(images/health-summary-bt1.png) no-repeat;" class="leftnav" onMouseOver="changeBgImage('images/health-summary-bt2.png', 'health')" onMouseOut="changeBgImage('images/health-summary-bt1.png', 'health')">Health Summary</div></a>
<a href="Basic_info?action=clinical-summary:"><div id="clinical" style="background:url(images/clinical-summary-bt1.png) no-repeat;" class="leftnav" onMouseOver="changeBgImage('images/clinical-summary-bt2.png', 'clinical')" onMouseOut="changeBgImage('images/clinical-summary-bt1.png', 'clinical')">Clinical Summary</div></a>
<a href="Basic_info?action=employer-guarantor:"><div id="gurantor" style="background:url(images/employer-gurantor-bt1.png) no-repeat;" class="leftnav" onMouseOver="changeBgImage('images/employer-gurantor-bt2.png', 'gurantor')" onMouseOut="changeBgImage('images/employer-gurantor-bt1.png', 'gurantor')">Employer Guarantor</div></a>
<a href="Basic_info?action=insurance:"><div id="insurance" style="background:url(images/insurance-bt1.png) no-repeat;" class="leftnav" onMouseOver="changeBgImage('images/insurance-bt2.png', 'insurance')" onMouseOut="changeBgImage('images/insurance-bt1.png', 'insurance')">Insurance</div></a>
<a href="Basic_info?action=patienthistory:"><div id="history" style="background:url(images/patient-history-bt1.png) no-repeat;" class="leftnav" onMouseOver="changeBgImage('images/patient-history-bt2.png', 'history')" onMouseOut="changeBgImage('images/patient-history-bt1.png', 'history')">Patient History</div></a>
<a href="Basic_info?action=logout:"><div id="logout" style="background:url(images/logout-bt1.png) no-repeat;" class="leftnav" onMouseOver="changeBgImage('images/logout-bt2.png', 'logout')" onMouseOut="changeBgImage('images/logout-bt1.png', 'logout')">Logout</div></a>
</div>
<div class="m8"> </div>
</td>
<td valign="top" class="m4">
<div class="m4a">Appointments</div>
<div class="m6">
<form action="#" method="post" name="reg" id="reg">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div class="m12">
<table border="0" cellspacing="1" cellpadding="2">
<tr>
<td style="width: 15%;">Location</td>
<td style="width: 35%;"><select name="Location" id="Location"
class="drop2">
<option value="0">-Select-</option>
<% for(int i=0;i<miniFacilities.length;i++)%>
<option value="<%=miniFacilities[i].getiFacilityId()%>"
<%if(patient.getsState().equals(miniFacilities[i].getiFacilityId()))out.println("selected='selected'"); %>><%=miniFacilities[i].getsFacilityName()%></option>
<% %>
</select></td>
<td style="width: 15%;">Provider</td>
<td style="width: 35%;"><select name="Provider"
id="Provider" class="drop2">
<option value="">-Select-</option>
<% for(int i=0;i<miniProviders.length;i++)%>
<option value="<%=miniProviders[i].getiProviderId()%>"
<%if(patient.getsState().equals(miniProviders[i].getiProviderId()))out.println("selected='selected'"); %>><%=miniProviders[i].getsProviderName()%></option>
<% %>
</select><br />
<span id="username_warning" style="color: red"></span></td>
</tr>
<tr>
<td>Appointment Date Format</td>
<td><span style="width: 35%;"> <select
name="Appointment" id="Appointment" class="drop2">
<option value="0" selected="selected">-Select-</option>
<option value="Earliest available date">Earliest
available date</option>
<option value="Allow me to pick a Date">Allow me to
pick a Date</option>
</select> </span></td>
<td id="AppointmentDate">Appointment Date</td>
<td bgcolor="#F5F5F5" style="width: 15%;"><input type="text"
name="date" id="date" tabindex="1" class="m10 autocompletehealth"
value="" /></td>
</tr>
<tr>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><input type="button" name="button" id="button"
value="SEARCH" class="bt-press" onclick=""
onmouseover="changeBgImage('images/button-bg2.png', 'update')"
onmouseout="changeBgImage('images/button-bg.png', 'update')" />
</td>
</tr>
</table>
<div id="divId"></div>
</div>
</td>
</tr>
<input type="hidden" name="page" value="appoinments2" class="m10" />
<input type="hidden" name="value" value="" class="m10" id="value"/>
</table>
</form>
</div><!--
<div class="m7"> <br />
</div>
-->
</td>
</tr>
</table>
<!--<div class="foot">GMQ Physician Associates, 100-C, Foley, AL 3655 TEL: (456)789-2343 FAX: (456)789-2343</div>
-->
</div>
<script>
var count=0;
$(document).ready(function()
//$("#date").hide();
//$("#AppointmentDate").hide();
// alert("");
$( "#date" ).datepicker( minDate: 0 , dateFormat: "mm-dd-yy");
);
$("#Appointment").change(function()
// alert($(this).val());
// $("#date").removeAttr("disabled");
// $( "#Appointment" ).datepicker( minDate: 0 , dateFormat: "yy-mm-dd");
$('#Appointment').live('change', function()
// alert($(this).val());
if ($(this).val() == "Allow me to pick a Date")
$("#mm").show();
// $("#date").show();
// $("#AppointmentDate").show();
$("#date").datepicker(showOn:'both',dateFormat: "mm-dd-yy").focus();
if ($(this).val() == "Earliest available date")
$("#mm").hide();
// $("#date").hide();
// $("#AppointmentDate").hide();
);
);
$('#next').live('click', function()
//alert("next");
$("#username_warning").empty();
if($('#Provider').val()=="")
var username_length;
username_length = $("#Provider").val().length;
if (username_length <1)
$("#username_warning").append("Please select a provider");
return false;
else
if(count<1)
//alert(count+"less");
count=1;
else
count=count+1;
//alert(count+"grater");
//alert(count);
$('#value').val(count);
///alert($('#value').val()+"count");
//$("#value").value(count);
//alert( $("#value").value());
makedate();
);
$('#back').live('click', function()
//alert("aaaa");
$("#username_warning").empty();
if($('#Provider').val()=="")
var username_length;
username_length = $("#Provider").val().length;
if (username_length <1)
$("#username_warning").append("Please select a provider");
return false;
else
if(count<=1)
//alert(count+"less");
count=1;
else
count=count-1;
//alert(count+"grater");
//alert(count);
$('#value').val(count);
///alert($('#value').val()+"count");
//$("#value").value(count);
//alert( $("#value").value());
makedate();
);
$("#button").click(function()
//alert(count);
$("#username_warning").empty();
if($('#Provider').val()=="")
var username_length;
username_length = $("#Provider").val().length;
if (username_length <1)
$("#username_warning").append("Please select a provider");
return false;
else
if($('#value').val()>count)
var count1 = $("#value").val();
count1 = parseInt(count1);
count=count1+1;
else
count=count+1;
$('#value').val(count);
//$("#divId br").remove();
//alert("CALLING");
makedate();
//alert("finished");
//$("#divId br").remove();
);
$('#date').change(function()
//alert("change") ;
$('#value').val("0");
count=0;
//alert($('#value').val()+"change");
);
var select=false;
$("#appoinmentdate").live('click', function()
// alert("inside");
select=true;
);
$("#reg").live('submit', function()
//alert("true0");
if(select== true)
//alert("true");
else
//$("#ps").attr("style=", "display: block;");
return false;
);
</script>
</body>
</html>
这是我用于填充值的 ajax 函数
function makedate()
$('#button').attr( 'disabled', 'disabled' );
$.ajax(
type: 'POST',
url: 'ajaXForgetdatesForAppoinment.jsp?' +
$('#reg').serialize(),
dataType: 'text',
success: function( data )
//alert(data);
$('#button').removeAttr( 'disabled' );
$('#divId').html(data);
,
error: function( jqXHR, textStatus, errorThrown )
// ...
);
这是我的 jsp 页面,从中我将值填充到上面的 jsp 页面
<%@page import="pojo.AppoinmentTimedetails"%>
<%@page import="classes.AppoinmentInfo"%>
<%
int clinicid=(Integer)session.getAttribute("clinicid");
String date=null;
String Location=null;
String Provider="";
String Appointmentdateformat="";
String value="";
//
value=request.getParameter("value");
date=request.getParameter("date");
Location=request.getParameter("Location");
Provider=request.getParameter("Provider");
Appointmentdateformat=request.getParameter("Appointmentdateformat");
System.out.print(date+Location+Provider+Appointmentdateformat);
AppoinmentInfo appoinmentInfo=new AppoinmentInfo();
AppoinmentTimedetails appoinmentTimedetails=new AppoinmentTimedetails();
appoinmentTimedetails.setsLocation(Location);
appoinmentTimedetails.setsProvider(Provider);
appoinmentTimedetails.setsAppointmentdateinput(date);
appoinmentTimedetails.setsAppointmentdateformat(Appointmentdateformat);
appoinmentTimedetails=appoinmentInfo .getAppoinmenttime(appoinmentTimedetails,value, 83622);
%>
<table>
<%if(appoinmentTimedetails.getsAppoinmentTime()==null)%>
<tr><td align="center">
<strong ><font color="red">No appoitnments available on this date</font></strong></td></tr> <%else%>
<tr><td></td><td>
<input type="button" name="back" id="back" style="background: url(images/button_previous_01.png);width 100 px" />
<strong>PICK YOUR APPOINTMENT</strong>
<input type="button" name="next" id="next"class="" style="background: url(images/button_next_01.png)" />
</td>
</tr>
<%for(int i=0;i<appoinmentTimedetails.getsAppoinmentTime().length;i++) %>
<tr>
<td></td><td>
<input type="radio" name="appoinmentdate" id="appoinmentdate"value="<%=appoinmentTimedetails.getsAppoinmentTime()[i] %>"/><%=appoinmentTimedetails.getsAppoinmentTime()[i] %>
</td><br></tr><%%>
<!--<p align=left><font color="red">click on search button to show more opening</font></p>
-->
<tr>
<td >Complaints
</td>
<td><input type="text" name="Complaints" id="Complaints" class="m10" /></td>
</tr>
<tr>
<td>Notes</td>
<td><textarea name="Notes" class="m14" id="Notes"></textarea></td> </tr>
<tr>
<td></td> <td>
<input type="submit" name="CREATE" id="CREATE" value="CREATE" class="bt-press" onclick=""onmouseover="changeBgImage('images/button-bg2.png', 'update')" onmouseout="changeBgImage('images/button-bg.png', 'update')" />
<div id="ps" style="visibility: hidden"> <p align=lef id="p"><font color="red">pls select any appointment </font></p></div>
</td>
</tr>
<%%>
</table>
这就是我在那个 div id "divId" 上得到的结果
<div id="divId">
<br><br><br><table>
<tbody><tr><td></td><td>
<input type="button" name="back" id="back" style="background: url(images/button_previous_01.png);width 100 px">
<strong>PICK YOUR APPOINTMENT</strong>
<input type="button" name="next" id="next" class="" style="background: url(images/button_next_01.png)">
</td>
</tr>
<tr>
<td></td><td>
<input type="radio" name="appoinmentdate" id="appoinmentdate" value="Tuesday, 18 June 2013, 08:00 AM">Tuesday, 18 June 2013, 08:00 AM
</td></tr>
<tr>
<td></td><td>
<input type="radio" name="appoinmentdate" id="appoinmentdate" value="Tuesday, 18 June 2013, 08:15 AM">Tuesday, 18 June 2013, 08:15 AM
</td></tr>
<tr>
<td></td><td>
<input type="radio" name="appoinmentdate" id="appoinmentdate" value="Tuesday, 18 June 2013, 08:30 AM">Tuesday, 18 June 2013, 08:30 AM
</td></tr>
<!--<p align=left><font color="red">click on search button to show more opening</font></p>
-->
<tr>
<td>Complaints
</td>
<td><input type="text" name="Complaints" id="Complaints" class="m10"></td>
</tr>
<tr>
<td>Notes</td>
<td><textarea name="Notes" class="m14" id="Notes"></textarea></td> </tr>
<tr>
<td></td> <td>
<input type="submit" name="CREATE" id="CREATE" value="CREATE" class="bt-press" onclick="" onmouseover="changeBgImage('images/button-bg2.png', 'update')" onmouseout="changeBgImage('images/button-bg.png', 'update')">
<div id="ps" style="visibility: hidden"> <p align="lef" id="p"><font color="red">pls select any appointment </font></p></div>
</td>
</tr>
</tbody></table>
</div>
谁能帮我解决这个问题
【问题讨论】:
【参考方案1】:只要您网站上的任何地方都不需要br
,只需为br
写一个css
属性为display:none;
。
例如,
br display:none;
或
如果您的网站上需要br
标签,请为生成不需要的br
的div
添加div
id,然后将其添加到归因于该div
id 的css 中,然后放置一个display:none;
.
例如,
div#xx br display:none;
就像你的情况一样,divId
是你的 id,所以,
div#divId br display:none;
希望这会有所帮助。
【讨论】:
感谢它完美运行 不客气-@abhi以上是关于div中不需要的br标签[关闭]的主要内容,如果未能解决你的问题,请参考以下文章
克服 contenteditable 中不一致的 <br> 选择行为
Azure DevOps 服务标签在网络安全组中不可用 [关闭]