2015-04-17 86 views
0

我似乎無法得到jQuery的.hide()函數的工作。jQuery .hide()即時通訊做錯事

代碼

<img class="jh-search" src="http://www.placehold.it/100x100" /> 

$(document).ready(function(){ 
    $('.jh-search').click(function(){ 
     (this).hide(); 
    }); 
}); 

這裏有一個fiddle

回答

5

$(this)是當前上下文jQuery對象

$(document).ready(function(){ 
    $('.jh-search').click(function(){ 
     $(this).hide();  //$ to wrap as jQuery object. 
    }); 
}); 
+1

我感覺如此愚蠢的現在,謝謝。 – WAHLEET