[英]How to give a javascript function and css style in struts2 property tag
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script type="text/javascript">
$(function () {
$( "#startDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'yy-mm-dd'
});
});
</script>
<style type="text/css">
.search_textbx
{
background-image:url('/SalesPropeller/calendar.jpg');
background-repeat:no-repeat;
background-position:right;
}
</style>
In the above code,there is a javascript function and css style in which i am using those in <input>
tag as shown below 在上面的代码中,有一个javascript函数和css样式,其中我正在<input>
标记中使用它们,如下所示
<input type="text" id="startDate" name="startDate" class="search_textbx" size="15" readonly="readonly"/>
Here my question is i have struts2 tags and when i am using the same id="startDate"
and class="search_textbx"
in the below code,it is showing an error.I am completely new to struts2 so any help will be appreciated. 在这里,我的问题是我有struts2标记,当我在下面的代码中使用相同的id="startDate"
和class="search_textbx"
时,它显示错误。我对struts2完全陌生,因此将不胜感激。
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>
<%@taglib prefix="bean" uri="/WEB-INF/struts-bean.tld" %>
<html:html>
<body>
<td style="padding-left:50px;">Lead Date </td>
<td><html:text property="leadDate" size="17.5"/></td>
<td><html:errors property="leadDate" /></td>
</body>
</html:html>
In struts2 we can use cssStyle attribute in struts2 tag like this... 在struts2中,我们可以像这样在struts2标签中使用cssStyle属性...
<s:a href="%{LogOut}" cssStyle="search_textbx"> <small> LogOut </small> </s:a>
<%@ taglib prefix="s" uri="/struts-tags" %>
What you are using its struts1 i belive check this link Using Struts 2 Tags 您正在使用其struts1的功能我相信请检查此链接使用Struts 2的标签
<td style="padding-left:50px;">Lead Date </td>
<td id="yourID"><s:text value="leadDate" size="17.5" cssStyle="search_textbx"></s:text></td>
<td id="yourID"><s:actionerror value="leadDate" cssStyle="search_textbx"></s:actionerror></td>
Give the id/class to the td element and change the css/js to select the input inside the td. 将id / class赋予td元素,然后更改css / js以选择td内的输入。
jsp: jsp:
<td id='startDate'><html:text property="leadDate" size="17.5"/></td>
<td class='search_textbx'><html:text property="leadDate" size="17.5"/></td>
css: CSS:
.search_textbx input
{
background-image:url('/SalesPropeller/calendar.jpg');
background-repeat:no-repeat;
background-position:right;
}
script: 脚本:
<script type="text/javascript">
$(function () {
$( "#startDate input" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'yy-mm-dd'
});
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.