zoukankan      html  css  js  c++  java
  • 点击评论加入输入框(笔记)

    <html>
    <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>评论</title>
    <style>
    .back{ 300px; height: 200px; background: #ccc;}
    .back span{ display: inline-block; vertical-align: top; 50px; background: #fff; height: 20px; margin:5px; text-align: center; cursor: pointer;}
    .back span.active{background: #0b8;}
    </style>
    </head>
    <body>
    <textarea class="ipt"></textarea>
    <div class="back">
    <span>红色</span>
    <span>黄色</span>
    <span>蓝色</span>
    <span>黑色</span>
    </div>
    </body>
    <script src="jq/jquery-1.7.2.js"></script>
    <script>
    $(function(){
    var arry=[];
    $('.back>span').click(function(){
    $(this).toggleClass('active');
    var a=false;
    for(var i=0;i<arry.length;i++){
    if(arry[i]==$(this).text()){
    arry.splice(i,1);
    $('.ipt').text(arry);
    a=true;
    };
    };
    if(a==true){
    return;
    }else{
    arry.push($(this).text());
    $('.ipt').text(arry);
    };
    });
    });
    </script>
    </html>

  • 相关阅读:
    [hdu5312]数的拆分,数学推导
    [POJ1038]状压DP
    [hdu2112]最短路
    [hdu1532]最大流
    [hdu5256]LIS模型
    [hdu5255]枚举
    [hdu5254]BFS
    [hdu5270]按位统计,容斥,归并
    Elasticsearch在Centos 7上的安装与配置
    手动安装java1.8
  • 原文地址:https://www.cnblogs.com/nameless-212/p/6420229.html
Copyright © 2011-2022 走看看