Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
            
                    
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        6年前关闭。
                    
                
        

我想使用click()函数返回HTML中表单的属性和值,然后将它们添加到字符串中。
这是我的代码。对于“表单”,我只想一次获得这些值,而“输入”标签可以多次检索:

var target="http://www.aaa.com/";
var clicktime=0;

$(document).ready(function(){
    $("form").click(function(){
    var c=this.method;
    var d=this.action;
    var e=d.substr(17)
    $("#test2").text("the method is:   " +c+"   "+"The action part is:"+ "    "+e);
    if (clicktime=0){
    target=target+e+"?";
    }
    clicktime=1;
    $("#test1").text("you choose the following links:"+ "    "+target);
    });
});

$(document).ready(function(){

    $("input").click(function(){
    var a=this.name;
    var b=this.value;
    target=target+a+"="+b+"&";
    $("#test1").text("you choose the following links:"+ "    "+target);
    });
});


在浏览器中单击表单部件后,结果应如下所示:

the method is get The action part is /dec/DEC

you choose the following links: http://www.aaa.com/


虽然我在浏览器中单击表单部分的结果是:

the method is get The action part is /dec/DEC

you choose the following links: http://www.aaa.com/dec/DEC


“ target = target + e +”?“”;无效!为什么?类似的功能在“ input”功能上效果很好!

最佳答案

if (clicktime=0)


应该

if (clicktime==0)


=是赋值运算符。
==是比较运算符。

09-27 00:43
查看更多