我不明白这里发生了什么.如果有人能解释,我会很感激.我需要创建一个照片库,并建议查看此代码,但我不明白它是如何工作的.
$(document).ready(function(){
imageSwapper(".thumbnails a");
});
function imageSwapper(link) {
$(link).click(function(){
$('#largeimage').attr('src', this.href);
return false;
});
};
Run Code Online (Sandbox Code Playgroud)
Gre*_*reg 10
像这样:
// When the document is ready
$(document).ready(function(){
// Call this function with this string (a CSS selector)
imageSwapper(".thumbnails a");
});
function imageSwapper(link) {
// With all the elements matching link (all the <a>'s under <tag class="thumbnails">)
// Set their onClick to be this anonymous function
$(link).click(function(){
// Get the element with id="largeimage"
// and set it's src attribute to the href of the link we clicked on
$('#largeimage').attr('src', this.href);
// Cancel the default action (don't go to the href of the link we clicked on
return false;
});
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
104 次 |
| 最近记录: |