I can't even get $().text to work properly. Outputs a massive string of code instead

javascript, jquery, jquery-selectors

Solution

'text' is a function, the code of which you are outputting

Just call it like any function

alert($('#test').text());

Problem

I've set up a test so I can begin using jQuery in a cakePHP environment but I'm having a problem before I've even started. I have twitter bootstrap also but when I had this problem I turned everything off to make sure it wasn't that. It wasn't. I'm testing this in Chrome & Waterfox. When I tried to `$('#test').html('Hello');` I didn't get anything. So I tried alerting something out using the following: ``` $(document).ready(function() { $('#test').click(function() { alert($('#test').text); }); }); ``` and ``` <span id="test">test span</span> ``` Which gives me the result: `function (a){return f.access(this,function(a){return a===b?f.text(this):this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a))},null,a,arguments.length)}` Could someone please tell me what the hell that is please and why didn't I get 'test span'. Thank you :)

Original source