jquery slidetoggle图像交换(jquery slidetoggle image swap)
我试图让slideToggle根据div是否展开或折叠来交换图像。 我让它以一种方式工作,它将图像从加号变为零,但它只适用于一个div而且我有多个,它只能工作一次。 它没有切换。
这是jQuery:
$(".content").toggle(1); $(".expand").click(function () { $(this).next(".content").slideToggle(400); if ($(".image1").attr('src', "../nathan/plus.png")) { $(".image1").attr( 'src', $(".image1").attr('src').replace('plus', 'minus') ); } else { $(".image1").attr( 'src', $(".image1").attr('src').replace('minus', 'plus') ); } }); });
IndexOf()有效,但是如果我要复制div,则在单击一个时它们都会改变。 这是HTML:
<div class="list"> <h2 class="expand">Title1<img class="image1" src="../nathan/plus.png"></h2> <div class="content"> </div> </div> <div class="list"> <h2 class="expand">Title2<img class="image1" src="../nathan/plus.png"></h2> <div class="content"> </div> </div>
I'm trying to get slideToggle to swap images based on if a div is expanded or collapsed. I have it working one way, where it will change an image from plus to minus, but it only works on one div and I have multiple and it only works once. It doesn't toggle.
Here is the jQuery:
$(".content").toggle(1); $(".expand").click(function () { $(this).next(".content").slideToggle(400); if ($(".image1").attr('src', "../nathan/plus.png")) { $(".image1").attr( 'src', $(".image1").attr('src').replace('plus', 'minus') ); } else { $(".image1").attr( 'src', $(".image1").attr('src').replace('minus', 'plus') ); } }); });
The IndexOf() works, but if I was to duplicate the divs they all change when one is clicked. Here is the HTML:
<div class="list"> <h2 class="expand">Title1<img class="image1" src="../nathan/plus.png"></h2> <div class="content"> </div> </div> <div class="list"> <h2 class="expand">Title2<img class="image1" src="../nathan/plus.png"></h2> <div class="content"> </div> </div>
原文:https://stackoverflow.com/questions/12273179
最满意答案
我想这可能对你有所帮助
create procedure Usp_project ( @projectid int ) As /* Exec Usp_project 6 */ if not exists(select projectid from project where projectid = @projectid) begin print('Projectid does not Exist') end
I think it may help you
create procedure Usp_project ( @projectid int ) As /* Exec Usp_project 6 */ if not exists(select projectid from project where projectid = @projectid) begin print('Projectid does not Exist') end
相关问答
更多-
您可以查询sys.dm_exec_requests ,它将提供sesion_ID,等待时间和更多感兴趣的行以及CROSS APPLY sys.dm_exec_sql_text用您的过程的SQL过滤您的查询。 Select * from ( SELECT * FROM sys.dm_exec_requests where sql_handle is not null ) a CROSS APPLY sys.dm_exec_sql_text(a.sql_handle) t where t.text li ...
-
您可以在能够运行查询的任何地方运行过程代码。 只需复制AS后的所有内容: BEGIN DECLARE @myvar INT SELECT * FROM mytable WHERE @myvar ... END 此代码与存储过程完全相同,但不会存储在数据库端。 这很像PL/SQL所谓的匿名过程。 更新: 你的问题有点混乱。 如果你只需要创建一个程序,如果它不存在,那么你的代码很好。 以下是创建脚本中SSMS输出的内容: IF EXISTS ( SELECT * ...
-
刚试过这种方法,它不起作用。 client.CreateStoredProcedureQuery( link, String.Format( "select * from root r where r.id = '{0}'", "spname1" ) ).ToList( ).FirstOrDefault( ); 返回null client.CreateStoredProcedureQuery( link, String.Format( "select * from root r" ) ).ToList( ...
-
您的每个客户都有自己的数据库吗? 如果是这样,最好的选择是使用条件编译 。 这具有不需要动态SQL的优点。 让主程序始终调用自定义过程,并使用CC标志来改变它包含的代码。 否则,Oracle确实有一个规则引擎,但它并不适合我们使用。 The final solution that we went with was to store the name of a procedure in a database table. We then build the SQL call and use an EXECUT ...
-
我想这可能对你有所帮助 create procedure Usp_project ( @projectid int ) As /* Exec Usp_project 6 */ if not exists(select projectid from project where projectid = @projectid) begin print('Projectid does not Exist') end I think it may he ...
-
CREATE PROC dbo.ProcB (@pb int) AS RETURN 2* @pb /*Double it*/ GO CREATE PROC dbo.ProcA (@pa int) AS DECLARE @ret INT EXEC @ret = dbo.ProcB @pb = @pa SELECT @ret as doubled GO EXEC dbo.ProcA @pa = 10 返回 doubled ----------- 20 CREATE PROC dbo.ProcB ( ...
-
您可以将其添加到过程脚本的顶部。 (只需用实际值替换ownerName和ProcName即可。 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[OwnerName].[ProcName]') AND type in (N'P', N'PC')) DROP PROCEDURE [OwnerName].[ProcName] GO 或者,您可以编写ALTER PROC ,但如果您将工作保存为脚本以便稍后部署到可能没有该过程 ...
-
存储过程?(Stored procedure?)[2023-04-26]
首先指定你真正需要的列 - >在你的查询中替换星号。 然后在视图列上创建索引(SortOrder DESC)。 其余的应该是好的:) First just specify the columns you really need -> replace the star in your query. Then create an index over the views column (SortOrder DESC). The rest should be OK :) -
检查存储过程是否有效(check if stored procedure is valid)[2021-09-17]
不幸的是,SQL Server中没有机制来测试依赖项,参数等 您必须搜索+检查 ,或提供参数的默认值。 你只会通过测试来捡起它。 像Red Gate SQL提示这样的自动完整工具可以为您列出参数+类型 注意: 这是一个长期存在的问题,甚至向MS提出要求,包括此。 SP参数检查是OPTION STRICT建议之一 Unfortunately, there is no mechanism in SQL Server to test dependencies, parameters etc You have to ... -
如何检查没有返回值的存储过程是否已执行?(How to check that a stored procedure with no return value has been executed?)[2021-10-17]
使用ExecuteNonQuery()时,存储过程将返回“受影响的行数”: DbCommand cmd = dbConnection.CreateCommand(); cmd.CommandText = "h_AS_SP_ResetUnfinishedJobs"; cmd.CommandType = CommandType.StoredProcedure; int rowsAffected = cmd.ExecuteNonQuery(); 这将让您了解是否有任何事情已经完成。 但是:如果不影响任何行也是存 ...