zoukankan      html  css  js  c++  java
  • offsetHeight 正则表达式验证格式

    获取Div 的height width等属性

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
         <style>
            #a {
            20%;
            height:50px;
            background-color:yellow;
            margin-left:2%;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="a"></div>
            <asp:Button ID="Button1" runat="server" Text="Button" />
        </form>
    </body>
    </html>
    <script>
        document.getElementById("Button1").onclick = function ()
        {
            var a = document.getElementById("a");
            alert(a.offsetHeight);//无论是在CSS里面还是Style里面都能取到值
            alert(a.style.width);//只能取到Style里面的值,不能取到CSS里面的值
        }
    </script>
    View Code

    正则表达式验证格式

    <script>
    if(/^正则表达式$/.test(a.innerText))//注意(.test)
    {
    alert("正确");
    }
    else
    {
    alert("错误");
    
    }
    
    
    
    
    </script>
    View Code
  • 相关阅读:
    问题 A: 走出迷宫(BFS)
    问题 A: 工作团队(并查集删点操作)
    刷题-力扣-989
    刷题-力扣-12
    刷题-力扣-628
    刷题-力扣-11
    刷题-力扣-1018
    刷题-力扣-9
    刷题-力扣-7
    刷题-力扣-6
  • 原文地址:https://www.cnblogs.com/wwz-wwz/p/5993666.html
Copyright © 2011-2022 走看看