.html () returns undefined
I am new to jQuery and it is hard for me to get the contents of a div block.
<div class="update_status"> Updated successfully </div> And when the following script is executed:
$(document).ready(function () { $(function () { var $status_div = $("#update_status"); if ($status_div) { alert("1"); alert($status_div.html()); alert("2"); } else { alert("undefined"); } }); }); I get three warnings: "1", "undefined" and "2". I expected to get "Updated successfully." Any ideas on what I did wrong?
+4
4 answers