Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XPATH的JQuery(!=)工作不正常 $(文档).ready(函数(){ $(“按钮”)。单击(函数(){ $(“[href!=”http://www.google.net“]”).hide(); }); }); 这是一个标题 这是一个段落 这是另一段 点击我_Jquery_Html - Fatal编程技术网

XPATH的JQuery(!=)工作不正常 $(文档).ready(函数(){ $(“按钮”)。单击(函数(){ $(“[href!=”http://www.google.net“]”).hide(); }); }); 这是一个标题 这是一个段落 这是另一段 点击我

XPATH的JQuery(!=)工作不正常 $(文档).ready(函数(){ $(“按钮”)。单击(函数(){ $(“[href!=”http://www.google.net“]”).hide(); }); }); 这是一个标题 这是一个段落 这是另一段 点击我,jquery,html,Jquery,Html,当我运行此代码时,整个页面变为空白。请帮助$(“[href!=”http://www.google.net“]”选择“href”属性不等于的所有项目(标记)http://www.google.net". 例如,标记没有属性“href”=>其值不等于http://www.google.net“=>它应该是隐藏的 试试这个: <html> <head> <script type="text/javascript" src="http://code.jquery.com/

当我运行此代码时,整个页面变为空白。请帮助

$(“[href!=”http://www.google.net“]”
选择“href”属性不等于的所有项目(标记)http://www.google.net". 例如,
标记没有属性“href”=>其值不等于http://www.google.net“=>它应该是隐藏的

试试这个:

<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    $("[href!='http://www.google.net']").hide();
  });
});
</script>
</head>

<body>
<h2>This is a heading</h2>
<p class="waqar">This is a paragraph.</p>
<p class="wr">This is another paragraph.</p>
<a href="http://www.google.net">google</a>
<a href="http://www.yahoo.com">yahoo</a>
<button>Click me</button>
</body>
</html>

$(文档).ready(函数(){
$(“按钮”)。单击(函数(){
$(“a[href!=”http://www.google.net“]”).toggle();
});
});
这是一个标题

这是一个段落

这是另一段

点击我
如何选择带有属性href或任何其他指定属性的所有标记?+1作为附加点,如果您想选择带有非Google属性的
href
的所有元素,您也可以使用:
$('[href][href!=”http://www.google.net“]”)
。当前,您正在选择所有标记(包括
,甚至可能是
)。如果要选择某个标记内的所有标记(例如
内的所有标记),请使用“父项>子项”选择器。例如:$(“body>[href!=”)
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    $("a[href!='http://www.google.net']").toggle();
  });
});
</script>
</head>

<body>
<h2>This is a heading</h2>
<p class="waqar">This is a paragraph.</p>
<p class="wr">This is another paragraph.</p>
<a href="http://www.google.net">google</a>
<a href="http://www.yahoo.com">yahoo</a>
<button>Click me</button>
</body>
</html>