Javascript examples for jQuery Method and Property:attr
JQuery toggle attribute value
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> <script type="text/javascript"> $(function(){//from w w w.j a va 2 s . com $('#contenteditable1').click(function() { $('#contenteditable1').attr('contenteditable',$(this).attr('contenteditable')==='true'?'false':'true' ); }); }); </script> </head> <body> <div contenteditable="true" id="contenteditable1"> CLICK </div> </body> </html>