javascript - Change Text function and then return -


OK, basically I set up a JavaScript code that changes the text on click, clicking on I have a problem again, I want to come back to it again in the same state as before before the change. I tried the return function, but I feel something wrong!

HTML:

  & lt; H5 & gt; & Lt; Div id = "open" & gt; Concept Art - & lt; / Div & gt; & Lt; / H5> Javascript: 
  $ (document) .ready (function () {$ ("# open") Click (function () $ {"$ Gallery" Use the div class = "post-text" itemprop = "text"> 

data attribute and check its status:

HTML

  & lt; H5> div = "open" data-state = "open"> concept art - 

JS

  $ (document) .ready (function () {$ ("# open"). Click (function () {// cache $$ (this); $ ("# Gallery3") Toggle (); if ($ this.data ('state') === 'open') {$ this.text ('Concept Art -') $ $ $ ('state', 'off');} and {$ this.text ("concept art +") $ this.data ('state', 'open')}} );});  


Comments