Same function for multiple jQuery objects
javascript, jquery
Solution
Try this:
$('textarea[type="text"], input[type="text"]').focus(...).blur(...);
Similarly you can also use jQuery's `add` function:
$('textarea[type="text"]').add('input[type="text"]').focus(...).blur(...);
Problem
I want the same functions to run for 2 jQuery objects: `$('input[type="text"]')` and `$('textarea[type=text]')`. How can I combine those two in the code below? (currently, only input is included). ``` $('input[type="text"]').focus(function() { if (this.value == this.defaultValue){ this.value = ''; } if(this.value != this.defaultValue){ this.select(); } }); $('input[type="text"]').blur(function() { if ($.trim(this.value == '')){ this.value = (this.defaultValue ? this.defaultValue : ''); } }); ``` Thanks!