如果一个句子包含"Hello World"(没有引号),那么我需要返回true并做一些事情.可能的句子可能是这样的:
var sentence = "This is my Hello World and I like widgets."
var sentence = "Hello World - the beginning of all"
var sentence = "Welcome to Hello World"
if ( sentence.contains('Hello World') ){
alert('Yes');
} else {
alert('No');
}
Run Code Online (Sandbox Code Playgroud)
我知道.contains不起作用,所以我正在找一些有用的东西.正则表达式是这里的敌人.
<div>
<div class="one">One</div>
<div class="two">Two</div>
<div class="three">Three</div>
<div class="four">Four</div>
<div class="five">Five</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要在div 3和Four之间添加一个div,但是我不能在父div上使用任何类型的目标(只有div里面的div).
jQuery('.four').parent().prepend('<div class="addme">Add Me!</div>');
Run Code Online (Sandbox Code Playgroud)
这可能是你可能知道的将它添加到顶部,在div之上.如果没有".parent()",它会在内容之前添加div四内部的div.".append()"的区别相同.
有人有解决方案吗?