Powiel możliwe:
Select inner text (jQuery)wartość Get elementu, na którym zdarzenie opalane
mam rozpiętość:
<span class="test"> target_string </span>
a zdarzenie, które jest opalane na kliknij dowolny element strony.
$('body').click(function(event){
if ($(event.target).attr('class') == 'test'){
alert(???);
}
}
Jak mogę uzyskać wartość target_string?
Dlaczego nie tylko '$ (this)'? – zerkms
@zerkms Ponieważ '$ (this)' odnosi się do ciała. –
@zerkms: Zdarzenie jest związane z '' body''. "this" będzie "body", a nie kliknięty element. –