Rollover function for input image buttons


/ Published in: jQuery
Save to your folder(s)

Each image button requires two images to represent two states: the off-state and the on-state. In this case, the on-state has "_ovr" appended.


Copy this code and paste it in your HTML
  1. // onrollover button for form submit image buttons - toggle "_ovr" to the filename
  2. $("form input[type='image'][src*='images/form_submit_']").hover(
  3. function () {
  4. $(this).attr('src', function() {
  5. return this.src.replace('.png', '_ovr.png');
  6. });
  7. },
  8. function () {
  9. $(this).attr('src', function() {
  10. return this.src.replace('_ovr', '');
  11. });
  12. }
  13. );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.