jQuery-editable is a tiny jQuery plugin that provides inline textual content enhancing to any HTML component by double-clicks. It may be helpful for duties like enhancing person profile information, in-place content material updates, or creating easy content material administration techniques.
The plugin transforms textual content parts into interactive inputs whereas preserving the unique content material. Customers can edit textual content by double-clicking, make modifications, and submit updates by urgent Enter or clicking exterior.
use it:
1. Obtain the bundle and cargo the jquery-editable.js file in your doc after you have included jQuery.
<!-- jQuery is required --> <script src="/path/to/cdn/jquery.min.js"></script> <!-- jquery-editable plugin --> <script src="/path/to/dist/jquery-editable.js"></script>
2. In case you’re utilizing a CommonJS surroundings, you’ll be able to set up it utilizing npm or yarn:
# NPM npm set up --save jquery-editable # Yarn yarn add jquery-editable
const $ = require("jquery") $.fn.editable = require("jquery-editable");
3. Name the operate ‘editable’ on the goal component:
<span class="editable">Double Click on </span> to Edit.
$(".editable").editable({ // choices right here })
4. Monitor textual content updates by the onChange callback:
$(".editable").editable({ onChange(val, oldVal) { console.log('New Worth: ' + val); console.log('Outdated Worth: ' + oldVal) } })
5. If you want to prohibit enter sorts, equivalent to solely accepting numbers, you’ll be able to customise the enter HTML:
$(".editable").editable({ inputHTML: "<enter kind="quantity" min='0' step='1' />", })
6. You’ll be able to even change what customers click on on to set off the edit mode. By default, it’s the component itself, however you’ll be able to set it to the guardian:
$(".editable").editable({ clickTarget: "guardian", })
This superior jQuery plugin is developed by Bloggify. For extra Superior Usages, please examine the demo web page or go to the official web site.