我正在尝试在页面上搜索文本,如果找到文本,请重新加载页面。
<p class="textmedium">These are the droids I'm looking for</p>
答案 0 :(得分:3)
这可以做到:
if($('*:contains("These are the droids I\'m looking for")').length > 0) {
document.href.location = document.href.location; // refresh the page
}
答案 1 :(得分:1)
我会说:
$("p.textmedium").each(function() {
if ($(this).html == "These are the droids I'm looking for") window.location.reload();
});
答案 2 :(得分:1)
用户jquery的javascript:
<p class="textmedium" id="ptag" >These are the droids I'm looking for</p>
<script type="text/javascript" >
var text = $("#ptag").html();
var isFound = text.search(/word-you-are-searching-for/i);
if(isFound){
document.href="page you redirect to";
}
</script>