javascript - Why is this hover toggle jQuery not working? -


i have separate jquery functions "mouseenter" , "mouseleave" work fine:

$('#imgposttravel').mouseenter(function () {     $('#imgposttravel').addclass('popout_image');     $('#imgposttravel').addclass('shadow'); });  $('#imgposttravel').mouseleave(function () {     $('#imgposttravel').removeclass('popout_image');     $('#imgposttravel').removeclass('shadow'); }); 

...but hoping consolidate 1 "hover" toggle operation.

i first want make sure works, tried following on jsfiddle here:

$( "ptverbiage" ).hover(function() {     $(this).val('yep!'); }, function() {     $(this).val('nope!'); }); 

i've tried several things besides setting value of "val" (changing "disabled" attr, changing color, backgroundcolor, etc.) none of them thing. wrong way hover/toggle, or what's wrong?

you seem missing #

$("ptverbiage") => $("#ptverbiage")

and

not .val() .text(); .val inputs

should

$( "#ptverbiage" ).hover(function() {   $(this).text('yep!'); }, function() {   $(this).text('nope!'); }); 

http://jsfiddle.net/n9sq7x8y/4/


Comments