Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find/detect any textarea in page using jQuery?

Tags:

jquery

tinymce

I want to put a function call in my pages called enableTinyMCE(); In that function I want to see if there are any textarea's in my page and if so do the tinyMCE.init() function. How do I detect if there are any textarea elements in the page?

like image 204
Jon Avatar asked Jun 04 '09 13:06

Jon


People also ask

How to get the textarea value in jQuery?

We can get the value of textarea in jQuery with the help of val() method . The val() method is used to get the values from the elements such as textarea, input and select. This method simply returns or sets the value attribute of the selected elements and is mostly used with the form elements.

How check textarea is empty in jQuery?

To check if the input text box is empty using jQuery, you can use the . val() method. It returns the value of a form element and undefined on an empty collection.

How to access textarea value?

Use the value property to get the value of a textarea, e.g. const value = textarea. value . The value property can be used to read and set the value of a textarea element. If the textarea is empty, an empty string is returned.


1 Answers

if( $('textarea').length > 0 ) {
    ...
}
like image 55
Mario Menger Avatar answered Sep 22 '22 07:09

Mario Menger