需要一手不起作用的JQuery函数

问题描述

我的JQuery函数应该修改隐藏表单字段的值,然后提交表单。但是不会。小提琴here

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
  $(function(){
    // when clicking the submit button
    $('.findme').click(function(){

        // Get the value of the clicked a tag
        var index = $(this).attr("id");

        // Strip out the prefix,leaving only the id
        var usethisID = index.substring(index.indexOf("_")+1 );
        alert('Value to post: ' + usethisID) ;

        // Make a hidden form field and set its value to usethisID
        var x = document.createElement("INPUT");
        x.setAttribute("type","hidden");
        x.setAttribute("name","xid");
        x.setAttribute("id","xid");
        x.setAttribute("value",usethisID);

        // submit the form
        $('#fruitform').submit();
        });
    });
</script>

解决方法

啊哈!它不会发布,因为我的标签的href属性为空...。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...