I want to highlight text with custom color after selecting text using a mouse, and also want to save it in the database corresponding to the user. Can anyone help me by giving me some idea or library?
<mark>
tag. Hence, you don't need a library, and can custom build it. You can do inline styling to give it the custom background color from the database, and even change the text color.Let me know if this helps :)
The code will be here in jquery. . To change the color you can use onmouseover
onclick
onchange
event ex:
<script>
$(document).ready(function(){
$(".your_text_class").onmouseover(function(){
$(this).css("background-color","white":"color","Black");
var isStore = $(this).attr("isStore");
if(!isStore){
$.ajax({
//here your can use the ajax to save your value to database
})
}
$(this).attr("isStore",1);
})
})
<script>
I used this $(this).attr("isStore",1);
to store value once in the database if not used then it will run every time when user mouseover on text Thanks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.