<input id="ttl"></input><textarea rows="68" maxlength="68" wrap="soft" id="md"></textarea><script type="text/javascript">    var title= $("#ttl").val();
        body= $("#md").val();
    console.log([title, body]); //--> ['', '']

All id's are unique, but empty strings are always returned, I tried without jquery, everything is the same: there are empty strings in the variables, but try to find out the value through the console, then everything works.

  • Answer # 1

    Of course, empty values ​​will be returned, but you don't have anything entered at the time of code execution.

    And by the way, the input is spelled differently:

    <input id="ttl"></input>                ^^^^^^^^ no need

    and so

    <input id="ttl" type="text">                 ^^^^^^^^^ desirable