javascript - Foucs on success message displayed in div after ajax call -
javascript - Foucs on success message displayed in div after ajax call -
div tag in jsp : <div class="okstatustext" id="message"></div> code in ajax call: if ("success" ==result) { document.getelementbyid("message").innerhtml = "data saved successfully"; }
i displaying message @ top of page , want focus on message when displayed.
there no meaning of applying focus() on div . elements input can made focus doing
$('input').focus(); it illustration . in case , if want focus or in actual meaning want highlight message , can alter background-color or color .
$("#message").html("data saved successfully").css({'background-color':'blue'}); or
$("#message").html("data saved successfully").css('color','blue'); if want user see message straight without scrolling , seek
$('html,body').animate({ scrolltop: $(this).offset().top - 50 },1000); the value 50 can varibale depending upon upto height want scroll . can alter value , check @ value suits status . after doing can apply css message more obvious .
hope helpful time .
thanks !!
javascript jquery ajax jsp spring-mvc
Comments
Post a Comment