0

我正在尝试在页面上搜索文本,如果找到文本,请重新加载页面。

<p class="textmedium">These are the droids I'm looking for</p>
4

3 回答 3

3

这应该这样做:

if($('*:contains("These are the droids I\'m looking for")').length > 0) {
    document.href.location = document.href.location; // refresh the page
}
于 2013-02-08T18:17:38.813 回答
2

我会说:

$("p.textmedium").each(function() {
    if ($(this).html == "These are the droids I'm looking for") window.location.reload();
});
于 2013-02-08T18:18:21.210 回答
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>
于 2013-02-08T18:20:38.510 回答