首页 \ 问答 \ jquery slidetoggle图像交换(jquery slidetoggle image swap)

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
更新时间:2022-11-11 08:11

最满意答案

我想这可能对你有所帮助

  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 ,但如果您将工作保存为脚本以便稍后部署到可能没有该过程 ...
  • 首先指定你真正需要的列 - >在你的查询中替换星号。 然后在视图列上创建索引(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 :)
  • 不幸的是,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 ...
  • 使用ExecuteNonQuery()时,存储过程将返回“受影响的行数”: DbCommand cmd = dbConnection.CreateCommand(); cmd.CommandText = "h_AS_SP_ResetUnfinishedJobs"; cmd.CommandType = CommandType.StoredProcedure; int rowsAffected = cmd.ExecuteNonQuery(); 这将让您了解是否有任何事情已经完成。 但是:如果不影响任何行也是存 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)