HOME > > > > >

:not(selector)

selector 以外の要素を取得する。

サンプル

h5、input、div、img以外の要素を取得する。

実行結果

リストの見出し

jQueryのてすと

  • リスト1
  • リスト2

test

aaaa

Javascript

  1. $('.execute').click(function(){
  2.     $(':not(h5,input,div,img)', $(this).parent()).css({
  3.         display: 'inline-block',
  4.         padding: 5,
  5.         border: '1px solid #009999'
  6.     });
  7. });

HTML

  1. <div class="jqTest">
  2.     <input type="button" value="jQuery *テスト" class="execute" />
  3.  
  4.     <h5>リストの見出し</h5>
  5.  
  6.     <div>
  7.         <p>jQueryのてすと</p>
  8.         <ul>
  9.             <li>リスト1</li>
  10.             <li>リスト2</li>
  11.         </ul>
  12.     </div>
  13.  
  14.     <p><span>test</span></p>
  15.  
  16.     <div>aaaa</div>
  17.  
  18.     <img src="/resource/icons/comment.gif" />
  19.  
  20.     <input type="text" name="data[tel]" value="電話暗号は入力できません" />
  21.  
  22.     <div><img src="/resource/icons/comment.gif" /></div>
  23. </div>