2

css position:relative; かどうかを知っている人はいますか? 機能を台無しにすることができます

    $('body').not($('.theDIV')).click(function(){
    alert('');

    });

または問題はどこかにありますか?

何が起こっているのかというと、ボタンをクリックすると表示される があり、div 自体を除いて、ボディのどこかをクリックすると hide() したいのです。HTML

<ul class='messages'> //these are made dynamically. should i use each() to go through all the elements?
<li>
    <div class='theDIV'></div>
    <input type='button'>
</li>
<li>
    <div class='theDIV'></div>
    <input type='button'>
</li>
<li>
    <div class='theDIV'></div>
    <input type='button'>
</li>
</ul>

初めてでわかりにくかったらごめんなさい

4

1 に答える 1

6

あなたができる

$('body').click(function(e){
   if(! $(e.target).hasClass('theDIV')){
     alert('clicked on something that has not the class theDIV');
   }

});
于 2012-03-15T11:23:02.877 に答える