Shai UI
Shai UI

Reputation: 51976

I'm trying to .Find() a TextArea inside a Div

 <div id='bla'>
   <textarea type='text' style='text-align:center; color:black; width:90px; border:1px     
    solid transparent; font-size:11px; margin:2px'>this is a test</textarea>
 </div>​​​​​​​​​​​​

 alert($('bla').find('textarea').css('border'))

but for some reason this returns 'undefined' any ideas why? I'm defining a border inside that style... :/

jsfiddle: http://jsfiddle.net/foreyez/yWgqD/

Upvotes: 1

Views: 7686

Answers (3)

Alex
Alex

Reputation: 35407

Missed the ID selector (#) before bla...

Instead, use the following:

alert($('#bla textarea').css('border'))

Upvotes: 7

GillesC
GillesC

Reputation: 10874

The selector only won't cut it, you forgot the dom ready part too.

$(function() {
    alert($('#bla').find('textarea').css('border'));
});

http://jsfiddle.net/yWgqD/1/

Also as selector this is cleaner

$('#bla textarea')

Upvotes: 0

James Johnson
James Johnson

Reputation: 46077

You need to use the # ID selector:

$("#bla").find("textarea").css("border");

Upvotes: 2

Related Questions