-1
<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>
このコードを実行すると、ページ全体が空白になります。助けてくださいXPATHのJQuery(!=)が正しく動作しない
がどのように私は属性HREFまたはその他の指定した属性を持つすべてのタグを選択するのでしょうか? – SMUsamaShah
+1さらに、Google以外の 'href'属性を持つ要素をすべて選択する場合は、[has属性セレクタ](http://api.jquery.com/has-attribute -selector /): '$( '[href] [href!=" http://www.google.net "]')'。 – lonesomeday
現在、すべてのタグ( '
'、' '、おそらくは' ')を選択しています。あるタグの中のすべてのタグ(例えば、 ''の中のすべてのタグ)を選択する場合は、「parent> child」セレクタを使用します。例:$( "body> [href!= 'http://google.com']) – shybovycha