Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

save text of div to localStorage, update localStorage when text is changed

// get the text
var text = $('#test').text();

// set the item in localStorage
localStorage.setItem('test', text);

// bind text to 'blur' event for div
$('#test').on('blur', function() {

    // check the new text
    var newText = $(this).text();

    // overwrite the old text
    localStorage.setItem('test', newText);

    // test if it works
    alert(localStorage.getItem('test'));

});
Comment

PREVIOUS NEXT
Code Example
Javascript :: update head tag metadata vue 
Javascript :: how to change string to array in javascript 
Javascript :: display toastr info 
Javascript :: JavaScript Nested Function 
Javascript :: useEffect react dependency 
Javascript :: set a variable in express.js 
Javascript :: how to update mongodb collection with a new field 
Javascript :: rows().remove 
Javascript :: react hero slider 
Javascript :: react usereducer hook 
Javascript :: create owl component react js 
Javascript :: reverse string javascript 
Javascript :: utc to est javascript 
Javascript :: spread and rest operator javascript 
Javascript :: get all database react native 
Javascript :: how to append a data to list in redux 
Javascript :: use two div id in jquery 
Javascript :: ways to open modal in angular 
Javascript :: javascript call stacks 
Javascript :: Counting instances of values in an object 
Javascript :: comparison operators in javascript 
Javascript :: duplicate text javascript 
Javascript :: react native border radius not working ios 
Javascript :: js clone obj 
Javascript :: how to create new route in express 
Javascript :: dropdown hide 
Javascript :: what are escape characters in javascript 
Javascript :: display json data in html table react 
Javascript :: indexof javascript 
Javascript :: write head node js 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =