JamesB JamesB -4 years ago 113
jQuery Question

Jquery text returning weird values

My code is gerating strange output, I just want to get value of an element, but it returns me some kind of code. Sorry if it was a fool question, I am starting in JavaScript:

function clicarBotao(id){
var text=$("#"+id).html;

<li id="1" class="botaoMenu" onclick="clicarBotao(1)">Menu 1</li>

Alert returns:

function ( value ) {
return jQuery.access( this, function( value ) {
var elem = this[0] || {},
i = 0,
l = this.length;

if ( value === undefined ) {
return elem.nodeType === 1 ?
elem.innerHTML.replace( rinlinejQuery, "" ) :

code does not end here ...

Answer Source

You need html(), not html. It is printing the function definition.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download