我试图根据文本类型的输入和突出显示文本进行简单的jQuery单词搜索.如何为多个单词执行此操作?此代码仅适用于单个字符.
HTML
<input type="text"/>
<div>John Resig
George Martin
Malcom John Sinclair
J. Ohn
Sample text
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
span {
background : red
}
Run Code Online (Sandbox Code Playgroud)
JS
$("input").keyup(function() {
var mysearchword = $("input:text").val();
var word = mysearchword;
$( "div:contains('"+word+"')" ).html(function(i,html) {
var re = new RegExp(word,"g");
return html.replace(re,'<span>'+word+'</span>')
});
});
Run Code Online (Sandbox Code Playgroud)
如何在Popup div中加载iframe内容.点击每个链接的每个链接将打开popup div,页面url将加载到popup div内的iframe href.
$(document).ready(function(){
$(".openpop").click(function(){
var x = $(this).attr('href');
alert(x);
y = x.replace('#', '');
alert(y);
$(".popup").toggle();
$("iframe").attr("href", y);
});
$(".close").click(function(){
$(this).parent().fadeOut("slow");
});
});
Run Code Online (Sandbox Code Playgroud)
HTML
<a class="openpop" href="#http://www.google.com">Link 1</a>
<a class="openpop" href="#http://www.yahoo.com">Link 2</a>
<a class="openpop" href="#http://www.w3schools.com">Link 3</a>
<div class="wrapper">
<div class="popup">
<iframe src="">
<p>Your browser does not support iframes.</p>
</iframe>
<a href="#" class="close">X</a></div>
</div>
Run Code Online (Sandbox Code Playgroud) 我想插入一个段落元素<p>在年底<body>之前只是,</body>.
我尝试insertBefore()过如下,但它没有按预期工作.
$( "<p>Test</p>" ).insertBefore( "</body>" );
Run Code Online (Sandbox Code Playgroud) 我想根据所附图像在react-bootstrap复选框标签内显示链接如何格式化侧面标签中的标签?请帮忙。
<Form.Check
className="checkbox-groove"
label="I agree to the {<a>terms and conditions</a>}"
name="group1"
/>
Run Code Online (Sandbox Code Playgroud)
https://codesandbox.io/s/display-link-inside-a-input-label-0vosse