小编Kar*_*ikh的帖子

是否可以使用 insertRule() 向 css 添加多个规则?

您好,这是 HTML 代码

<html>
<head>
 <link rel="stylesheet" type="text/css" href="Theme.css"> 
</head>
<body>
<div>
    <textarea id="ta" onpaste="functionItalic(event)" class="foostyle2"></textarea>
</div>
<div>
    <span style="font-weight: bolder; font-size: 20px;">
        <span id="1">Karan's</span>
     </span>
    <span style="font-weight: bolder; font-size: 24px; font-style: italic;">test</span>
</div>
<script>
function functionItalic(pasteEvent)
{
var textareacont = (pasteEvent.originalEvent || pasteEvent).clipboardData.getData("text/html");
console.log(textareacont);
var styleSheetList = document.styleSheets;
document.getElementById("1").className = "foostyle";
var stringCSS = ".foostyle{font-family: Times-Roman;font-size:10pt;color:rgb(0,0,0);font-style:normal;}";
styleSheetList[0].insertRule(stringCSS, styleSheetList[0].cssRules.length);

}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

当我运行这个文件时,一切正常并且样式被添加。

但是一旦我将 stringCSS 的值更改为

var stringCSS = ".foostyle{font-family: Times-Roman;font-size:10pt;color:rgb(0,0,0);font-style:normal;} .foostyle2{background: green;}";
Run Code Online (Sandbox Code Playgroud)

浏览器提供错误

SyntaxError: An invalid or illegal …
Run Code Online (Sandbox Code Playgroud)

javascript css

3
推荐指数
1
解决办法
2164
查看次数

正则表达式以十进制形式检测十进制数不固定的所有数字

我在notepad ++中编辑一个包含数字的HTML文件

x
x.x
x.x.x
x.x.x.x
x.x.x.x.x
Run Code Online (Sandbox Code Playgroud)

小数位数可以是零或更多.

其中x是ex的任何数字:

1 
or 
1.2
or
3.4.1
or 
401.23.5
Run Code Online (Sandbox Code Playgroud)

我想创建一个正则表达式来查找文件中的所有这些实例请帮忙

我试过以下正则表达式

For 5 Decimals [0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}
For 4 Decimals [0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}
For 3 Decimals [0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}
For 2 Decimals [0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}
For 1 Decimal  [0-9]{1,4}\.[0-9]{1,4}
Run Code Online (Sandbox Code Playgroud)

我必须单独使用这个正则表达式我想创建一个普遍检测任何小数的所有出现的正则表达式

regex notepad++

0
推荐指数
1
解决办法
996
查看次数

标签 统计

css ×1

javascript ×1

notepad++ ×1

regex ×1