by @kodeazy
JavaScript How to disable the text on clicking?
- To disable the text on clicking we follow below steps.
- First called the function to perform the action by using
onclick
. - we have to identify the tag and select the tag.
- To identify the tag I used
disableText
as my id and selected the tag and applyed thedisplay:none
style . - Below is the syntax.
$("#disableText").css("display","none");
-
Below is the sample example of disabling the text on clicking the text.
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> function disableTextFunc(){ $("#disableText").css("display","none"); } </script> </head> <body> <div id="disableText"onclick="disableTextFunc()" style="display: block; cursor: pointer;">click here to disable the text</div> </body> </html>