我的DIV范围如下:
---creating the tables
CREATE TABLE [dbo].[Table1]([PID] [int] NULL,[ProductDesc] [nvarchar](50) NULL,[ProductCode] [nvarchar](10) NULL) ON [PRIMARY]
CREATE TABLE [dbo].[Table2]([Date] [varchar](50) NULL,[PID] [int] NULL) ON [PRIMARY]
---insert script---
INSERT [dbo].[Table1] ([PID], [ProductDesc], [ProductCode]) VALUES (1, N'Packet-Eye', N'P001')
INSERT [dbo].[Table1] ([PID], [ProductDesc], [ProductCode]) VALUES (2, N'Wiggy', N'W099 ')
INSERT [dbo].[Table1] ([PID], [ProductDesc], [ProductCode]) VALUES (3, N'Wimax-Lite', N'W001')
INSERT [dbo].[Table1] ([PID], [ProductDesc], [ProductCode]) VALUES (4, N'Wimax-Home', N'e W002 ')
INSERT [dbo].[Table2] ([Date], [PID]) VALUES (N'1/14/2009 ', 1)
INSERT [dbo].[Table2] ([Date], [PID]) VALUES (N'1/15/2009 ', 1)
INSERT [dbo].[Table2] ([Date], [PID]) VALUES (N'2/1/2009', 2)
INSERT [dbo].[Table2] ([Date], [PID]) VALUES (N'3/3/2009', 3)
GO
SELECT *
FROM
(
SELECT t1.productdesc as pd,COUNT(month(t2.date))as dates,
DateName( month , DateAdd( month , MONTH(t2.date) , 0 ) - 1 ) as mon
FROM table1 t1 inner join table2 t2 on t1.pid=t2.pid
where year(date) between 2009
and 2010 group by productdesc,month(t2.date),month (t2.date)
) AS D
PIVOT
(
sum(dates)
FOR mon IN( [January],[February],[March],[April],[May],[June],[July],[August],[September],[October],[November],[December])
) AS P
[using pivot in sqlserver please find the result in the below image][1]
[1]: http://i.stack.imgur.com/jio6c.png
现在我设置可以将我的内容设置为跨度,例如:
<span class="foo">
<div class="bar">
Here is my <?php echo $DIV-CONTENT; ?>
</div>
</span>
现在我在一段更长的代码中使用了与上面完全相同的代码,但是我无法以某种方式取消设置此文本和.show()或者其他()我的&lt; DIV&GT;回来。
我认为这是可能的但是没有设置,删除,添加属性但不是我可以工作的。
我实际上不确定它是否可行,因为你真的需要&#34;重置&#34;这个页面?
答案 0 :(得分:2)
您的<div>
未被隐藏,完全被丢弃。你覆盖它。如果您想保留<div>
并将其放回内容中,则需要将其实际存储在变量中,以便稍后手动恢复。
// Store a handle to the div so we can restore it later
var div = $('span.foo div');
$('#clear').click(function () {
$('span.foo').text("This removed my innerDiv");
});
$('#restore').click(function () {
$('span.foo').html(div);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="foo">
<div class="bar">
Here is my <?php echo $DIV-CONTENT; ?>
</div>
</span>
<a href="#" id="clear">clear it</a>
<a href="#" id="restore">restore it</a>
答案 1 :(得分:0)
您可以使用Jquery切换它:
// jQuery
$(document).ready(function(){
//This is your button
$('#altern-panel-hided').toggle(
/*
first click.
Function that show a hided panel
and change the button text.
*/
function(e){
$('#panel-hided').slideDown();
$(this).text('hide the panel');
e.preventDefault();
},
/*
Secund click.
Function that hide the panel
and rechange the button text.
*/
function(e){
$('#panel-oculto').slideUp();
$(this).text('Show panel');
e.preventDefault();
}
);
我希望它可以帮到你