Satch3000
Satch3000

Reputation: 49404

JQuery Div value returns Undefined

I have a div:

<div class="form_result">hello</div>


 var mb = $('.form_result').text();
 alert("Value of div is: " + mb.value); 

The alert is returning Undefined.

Tried JQuery version 1.9.1 and 1.8.3 ...same result.

Upvotes: 0

Views: 95

Answers (2)

Karthick Kumar
Karthick Kumar

Reputation: 2361

alert("Value of div is: " + mb); do like this

Upvotes: 1

you don't need .value

alert("Value of div is: " + mb)

.text() get the text inside the div


.value is used for form elements like input,select,radio,checkbox

Upvotes: 2

Related Questions