Find value on loaded page

I have a page with a form with data filled in by ajax post; the values ​​of the page form fields load correctly, but I cannot get the loaded value from the function inside the page; here is an example:

<input type="text" id="mela">
<div style="border:1px solid black; display:none" id="vv">aaa</div>

<script>
  alert($("#mela").val());
  if ($("#mela").val()) {
    $("#vv").show();
  }
</script>

Question: how can I load the value of "mela"?

+3
source share
2 answers

It happened to me once. I solved the problem by lowering (or updating?) JQuery. Why don't you give it a try?

+1
source

If the value is loaded via AJAX, the safest way to make the new value available is to access it from the callback for the AJAX request.

jQuery .load(), , , complete.

$('someElement').load('/some/path', function() {
    alert($("#mela").val());
    if ($("#mela").val()) {
        $("#vv").show();
    }
});
+1

Source: https://habr.com/ru/post/1760530/


All Articles