Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

input:text + textarea selector in jquery

I am trying to do this:

$('input:text','textarea').focus(function () {
$(this).removeClass('wrong');
if (this.value == this.defaultValue){
$(this).val('');
}

But $('input:text','textarea') wont work as a selector. What am I doing wrong?

like image 761
Hakan Avatar asked Jan 20 '12 02:01

Hakan


People also ask

How to select text in input jQuery?

The select() event is applied to an element using jQuery when the user makes a text selection inside an element or on focus the element. This event is limited to some fields. Syntax: $("selected element").

What is input selector?

Description: Selects all input, textarea, select and button elements.

How use contains in jQuery?

jQuery :contains() SelectorThe :contains() selector selects elements containing the specified string. The string can be contained directly in the element as text, or in a child element. This is mostly used together with another selector to select the elements containing the text in a group (like in the example above).


1 Answers

Try $('input:text, textarea')

like image 165
Paul Avatar answered Nov 15 '22 18:11

Paul