Article View: pl.comp.lang.javascript
Article #49130Re: [jquery]Dezaktywacja <a>
From: Paweł Piskorz
Date: Sat, 04 Jul 2009 13:19
Date: Sat, 04 Jul 2009 13:19
36 lines
1785 bytes
1785 bytes
misiek pisze:
> $(document).ready(function (){
> $("a.thumb").each( function(i) {
> $(this).bind("click", function(){
> var tmp = $(this).attr("href");
> $("img.zmiana").attr({src: tmp});
> });
> });
> });
Na pytanie sam sobie odpowiedziałeś, ale i tak pozwolę sobie na kilka
uwag :)
Nie musisz używać each, to nie prototype*:
$(document).ready(function(){
$("a.thumb").bind("click", function(e){
var tmp = $(this).attr("href");
$("img.zmiana").attr({src: tmp});
});
});
A nawet możesz zrezygnować z $(document).ready:
$("a.thumb").live("click", function(e){
var tmp = $(this).attr("href");
$("img.zmiana").attr({src: tmp});
});
* nie wiem czy dobrze pamiętam, ale w prototype właśnie trzeba się
pałować z eachem.
--
message[autor="PablO"]::after {
content:"Pozdrawiam";
}
Technical Details
Message-ID:
<h2nksm$efu$1@inews.gazeta.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailReferences:
<h2j4ll$aq2$1@achot.icm.edu.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail From: Paweł Piskorz <nie.ma.maila@psikre.nie?> Newsgroups: pl.comp.lang.javascript Subject: Re: [jquery]Dezaktywacja <a> Date: Sat, 04 Jul 2009 15:19:17 +0200 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 36 Message-ID: <h2nksm$efu$1@inews.gazeta.pl> References: <h2j4ll$aq2$1@achot.icm.edu.pl> NNTP-Posting-Host: 93-181-190-153.as.kn.pl Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1246713558 14846 93.181.190.153 (4 Jul 2009 13:19:18 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Sat, 4 Jul 2009 13:19:18 +0000 (UTC) X-User: uhorek In-Reply-To: <h2j4ll$aq2$1@achot.icm.edu.pl> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.22) Gecko/20090605 Thunderbird/2.0.0.22 Mnenhy/0.7.6.666 Hamster/2.1.0.11 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit