The value is not inserted into the text box, does it work two days ago?

<html>
<head>

    <script type="text/javascript"

src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script type="text/javascript">

function insertParamIntoField(anchor, param, field) {
       var query = anchor.search.substring(1, anchor.search.length).split('&');

       for(var i = 0, kv; i < query.length; i++) {
          kv = query[i].split('=', 2);
          if (kv[0] == param) {
              field.val(kv[1]);

             return;
          }
       }
    }


$(function () {
    $("a.reply").click(function (e) {
       console.log("clicked");
       insertParamIntoField(this, "replyto", $("textarea"));
       e.preventDefault();
       return false; // prevent default action
    });
});

</script>
</head>
<body>
<textarea></textarea>
<a class="reply" href="?replyto=you">TEST</a>
</body>
</html>

what am I trying to do, when I click the link, the replyto parameter is inserted into the text box, in this example "you"it worked 2 days ago! I dnt know what is wrong

+3
source share
2 answers

Edit: I mistakenly assumed that you are using firebug, from the comments that I see you were not, and that installing it solved your problem. This line:

console.log("clicked");

It will explode if firebug is not installed and always in IE, when testing in an environment without console, be sure to delete any calls to it ... otherwise it will lead to a JavaScript error.

+1

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


All Articles