siblings question
siblings question
- $('img').each(function() {
- // define
- var $imgHover = $(this).attr('imgHover'), // swap image name, already gave by php
- $imgOut = $(this).attr('imgOut'); // origin image source
-
- $(this).data('isClicked', false);
-
- // click function
- $(this).click(function() {
- $(this)
- .data('isClicked', true)
- .siblings()
- .data('isClicked', false);
-
- // here is the question I want to ask
- // I need to get each attribute to change each image
- // can I catch each attribute when using siblings?
- // and then I can do this function in above code
- $('img').not(this).each(function() {
- $(this).attr('src', $(this).attr('imgOut'));
- });
-
- return false;
- });
-
- // hover function
- $(this).hover(function() {
- $(this).attr('src', $imgHover);
- }, function() {
- if (!$(this).data('isChecked')) {
- $(this).attr('src', $imgOut);
- }
- });
- });