Monday 15 September 2014

click - Elements Hiding When Clicked document jQuery -



click - Elements Hiding When Clicked document jQuery -

js fiddle

here hiding buttons if textarea empty , user clicks outside of textarea. when textarea empty , user clicks of buttons below buttons should not hide run respective functions . can help me ?

on blur event of textarea, added check if button's parent div (.tog) hovered, if yes, don't hide that.

updated javascript:

$('textarea').focus(function () { $('.tog').hide(); $(this).siblings('.tog').show(); }).blur(function () { // check if hover on buttons if ((!$(this).val().length > 0) && (!$(this).siblings('.tog').is(':hover'))) { $(this).siblings('.tog').hide(); } }); $('.upload').click(function () { alert('choose file upload'); }); $('.clear').click(function () { alert('cleared'); }); $('.save').click(function () { alert('saved'); });

fiddle

jquery click toggle

No comments:

Post a Comment