为什么显示:none没有隐藏struts2标签,如< s:textfield> [英] why display:none does not hide struts2 tag like <s:textfield>

查看:106
本文介绍了为什么显示:none没有隐藏struts2标签,如< s:textfield>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道为什么 div 标签无法隐藏Struts2标签,我正在使用一个应该在加载时隐藏的div, onChange 我在调用切换 div 标签的jQuery ...

I wonder why the div tag is not able to hide the Struts2 tags, i am using a div which should hide on load,and onChange I am calling jQuery which toggles the div tag...

<%@ taglib prefix="s" uri="/struts-tags" %>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" >
$( document ).ready(function() {
    $("#t").click(function(){
        alert("I Know Its Not Working");
        $('#tt').toggle();
    });
    });
    </script>
</head>
<body>
<s:form >
<div style="display: none;" id="tt">
<s:textfield></s:textfield>
</div>
</s:form>
<input type="button" id="t">
</body>
</html>


推荐答案

默认情况下,Struts2使用 xhtml 用于生成 textfield 标签等表单字段的html内容的主题。此主题针对输入元素使用< table> 布局,其中< tr>< td> 。这会破坏你的设计,因为这些元素被放置在< div> 标签之外。如果您要为输入字段使用< div> ,而不是< tr>< td> ,那么你可以选择 css_xhtml 主题。如果您不想生成< tr>< td> < div> ,您可以使用简单主题。例如

By default Struts2 uses xhtml theme for generating html content of form fields like textfield tag. This theme is using a <table> layout with <tr><td> for input elements. This breaks your design because these elements is placed outside <div> tag. If you want to use <div> instead of <tr><td> for your input fields then you can choose css_xhtml theme. If you want to omit to generate <tr><td> or <div> then you can use simple theme. For example

<s:form theme="simple">
 <div style="display: none;" id="tt">
   <s:textfield name="myfield" />
 </div>
</s:form>

这篇关于为什么显示:none没有隐藏struts2标签,如&lt; s:textfield&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆