zoukankan      html  css  js  c++  java
  • 如果删除行内样式中某一个 属性

    如果删除行内样式中某一个 属性,

    例下面: H2 本身有 font-size:12px; margin:0; padding:0;

    点击事件  加了一个 border","1px dashed red",

    则次点击 把 border 去了,  保留font-size:12px; margin:0; padding:0;

    如何实现

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    </head>
    
    <body>
    <div class="oDiv">
      <h2 style="font-size:12px; margin:0; padding:0;">无标题文档无标题文档无标题文档无标题文档</h2>
    </div>
    </body>
    </html>
    <script type="text/javascript" src="jquery-1.11.1.min.js"></script>
    <script type="text/javascript">
    
    
    $(function(){
        
         $("h2").click(function(){
               
               $(this).css("border","1px dashed red");
               
                var objs=$(this).attr("style");
                
             })
        
        })
    </script>

      估计也有其它办法   现在在朋友的帮忙下, 用一个全局变量 做了一个判断, 也能实现 切换的效果
    代码如下:

    <script type="text/javascript">
    $(function(){
        var NoY=1;
         $("h2").click(function(){
                if(NoY==1){
                     $(this).css("border","1px dashed red");
                     NoY=0;
               
                    }else{
                         $(this).css("border","none");
                         NoY=1;
                        }
                
             })
        
        })
    </script>
  • 相关阅读:
    MySQL基础(二)
    MySQL练习题
    前端基础之css
    前端基础之初识HTML
    Ubuntu14.04 + Text-Detection-with-FRCN(CPU)
    简单HOG+SVM mnist手写数字分类
    汽车检测SIFT+BOW+SVM
    4. Neural Network
    2. Linear Model
    OpenCV2计算机编程手册(二)基于类的图像处理
  • 原文地址:https://www.cnblogs.com/yjhua/p/4806543.html
Copyright © 2011-2022 走看看