本地新建个html,复制以下代码,浏览器打开看效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="author" content="Vitaliy Potapov"> <meta http-equiv="cache-control" content="max-age=0"/> <meta http-equiv="cache-control" content="no-cache"/> <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"/> <meta http-equiv="pragma" content="no-cache"/> <title>X-editable Demo</title> <script src="http://vitalets.github.io/x-editable/assets/jquery/jquery-1.9.1.min.js"></script> <script src="http://vitalets.github.io/x-editable/assets/mockjax/jquery.mockjax.js"></script> <link href="http://vitalets.github.io/x-editable/assets/bootstrap/css/bootstrap.css" rel="stylesheet"> <link href="http://vitalets.github.io/x-editable/assets/bootstrap/css/bootstrap-responsive.css" rel="stylesheet"> <script src="http://vitalets.github.io/x-editable/assets/bootstrap/js/bootstrap.js"></script> <link href="http://vitalets.github.io/x-editable/assets/x-editable/bootstrap-editable/css/bootstrap-editable.css" rel="stylesheet"> <script src="http://vitalets.github.io/x-editable/assets/x-editable/bootstrap-editable/js/bootstrap-editable.js"></script> </head> <body> <a href="#" style="margin:700px;" id="username" data-type="text" data-pk="1" data-title="Enter username">superuser</a> </body> </html> <script> $(function () { $.fn.editable.defaults.url = '/post'; $('#username').editable({ url: '/post', type: 'text', pk: 1, name: 'username', title: 'Enter username' }); }); </script>