Richa
Richa

Reputation: 3289

Check whether data in Div is edited

I am editing content in <div>. Now I want to check whether the data in <div> is edited or not and If it is edited then save it in session and return on refresh.

How can I check whether the data is edited or not and then save it in session?

Following is JS fiddle for Edit .

Js Fiddle

If more information is needed please do tell.

Thanks for the help.

Upvotes: 0

Views: 180

Answers (1)

loxxy
loxxy

Reputation: 13151

One simple solution is

  • Save the div contents on click of edit.

    data = $(this).siblings('.panel-title').html();    
    
  • Compare the saved content & current content on click of done.

    data != $(this).siblings('.panel-title').html()
    
  • If it's edited then simply store into the cookie or localstorage.

  • If you are talking about the server session, then you could make an ajax call & the server side application will be responsible to save the data into session.

Something like this.

Upvotes: 1

Related Questions