我正在尝试返回调用该函数的字符串.
但它不返回字符串...它返回一个数组.
String.prototype.testing = function testing() {
if (this === "what") {}
return this //Should return - this is a string
}
x = "this is a string"
y = x.testing()
console.log(y)Run Code Online (Sandbox Code Playgroud)
是否Javascript有内置CSS index我可以检查句子?
在这一刻…
如果我想检查下面的句子 for CSS properties,我必须创建一个arraywith ……(( ALL ))CSS properties.然后根据整个句子检查每个句子array.
大批
css_checker = [
"width","height","background","background color", "text decoration line", "right",
"table layout", "page break before", //and on… and… on and on………………
// I really don't want to use this array
// Using this is like a last resort
// I was hoping for a better way than this
]
Run Code Online (Sandbox Code Playgroud)
输入
a = "A CSS property named …Run Code Online (Sandbox Code Playgroud) 有没有相当于
.setAttribute()的attribute东西:增加了类似的东西:
.addToAttribute()
它不是重置整个属性值......而是添加到当前值.
抬头
属性可以是任何东西:名称,标识,标题......等
我需要随意添加到任何属性而不仅仅是class
function one() {
body = document.body
div = document.createElement('div')
body.appendChild(div)
div.setAttribute("class", "blue")
div.setAttribute("name", "John")
div.setAttribute("id", "box")
}
one()
//should be
//name="John new value"
div.setAttribute("name", "new value")
// Is there something equivalent to .setAttribute()?
// Like .addToAttribue()?
console.log(document.getElementById('box'))Run Code Online (Sandbox Code Playgroud)
.blue {
width: 100px;
height: 100px;
background: red;
background: blue;
}
[name~="value"] {
border-radius: 50%;
}Run Code Online (Sandbox Code Playgroud)
function one() {
body = document.body
div = document.createElement('div')
body.appendChild(div)
div.setAttribute("class", "blue")
div.setAttribute("name", "name") …Run Code Online (Sandbox Code Playgroud)