user9134695
user9134695

Reputation:

How to select an element with a custom classname with jQuery

I want to select a textarea element which has a classname sendMessage with jQuery:

<script>tinymce.init({ selector:'textarea' });</script>

So how can I add the classname of that particular element to this line of code?

Upvotes: 1

Views: 101

Answers (2)

Zakaria Acharki
Zakaria Acharki

Reputation: 67505

Working fiddle.

You could use simply the class sign (dot) ., it will look like :

tinymce.init({ selector:'.sendMessage ' });
//or
tinymce.init({ selector:'textarea.sendMessage ' });

Snippet:

tinymce.init({
  selector: "textarea.sendMessage"
});
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea class="sendMessage">Congratulations!</textarea>

Upvotes: 0

Nitesh Kumar
Nitesh Kumar

Reputation: 1774

Class selector is represented by dot (.) like below

<script>
    tinymce.init({ selector:'textarea.sendMessage' });
</script>

Upvotes: 2

Related Questions