当项目点击时在javascript中打出一个单词 [英] Strike out a word in javascript when item clicked

查看:219
本文介绍了当项目点击时在javascript中打出一个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在项目点击时在javascript / jquery中打出一个单词。

Strike out a word in javascript/jquery when item clicked.

所以我点击和项目,项目淡出,但在同一时间我想要的文本

So I am clicking and item ,the item fades out but in the same time I want the text to strike out.

例如。我有一个苹果(图像)和一个苹果(文本)。当我点击苹果我想要的图像淡出和文本出去。

Ex. I have an apple(image) and a apple(text). When I click on the apple I want the image to fade out and the text to strike out.

<div id="items">
  <p>Apple</p>
</div>
<div id="content">
  <div class="box" id="pic1"> <img src = /images/apple.png  /></div>
    <script>
      $("#pic1").click(function () {
        $("#pic1").fadeOut("slow");
       });
    </script>

这是我的代码,直到图像淡出,但我不知道如何使文本删除???

This is my code until the image fades out but I cannot figure out how can I make the text to strike out???

推荐答案

jsFiddle演示

jsFiddle Demo

您可以将文本包含在< del>

$("#pic1").click(function () {
 $("#items p").wrap("<del>");
 $("#pic1").fadeOut("slow");
});

这篇关于当项目点击时在javascript中打出一个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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