小编All*_*all的帖子

如果为false,如何从原型返回输入

我正在尝试返回调用该函数的字符串.

但它不返回字符串...它返回一个数组.

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

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

如何使用Javascript检查任何CSS属性是否在字符串中?

检查 1,000 多个句子的代码

是否Javascript有内置CSS index我可以检查句子?

在这一刻…

如果我想检查下面的句子 f​​or 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)

javascript jquery

2
推荐指数
1
解决办法
96
查看次数

如何添加到现有属性?

有没有相当于
.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)

javascript

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

标签 统计

javascript ×3

jquery ×1