foreach object/array in jQuery

后端 未结 5 2060
滥情空心
滥情空心 2021-02-08 15:02

I have a problem, i have X in my code, now I want to foreach this object/array its out put. - look my code.

$(\"#d         


        
5条回答
  •  旧时难觅i
    2021-02-08 15:44

    Can it be that - ultimately - you are looking for $.serializeArray() or $.serialize()?

    If not, then maybe this is helps you:

    $("#denied_seekrs").click(function()
    { 
        if (!isCheckedById("selectname")) 
        { 
            alert ("Please select at least one event"); 
            return false; 
        } 
        else 
        { 
            // prepare array of values
            var values = [];
    
            // prepare list of checked checkboxes
            var $checkboxes = $("input[@id=selectname]:checked");
    
            // push each individual value into the array
            $checkboxes.each(function() { values.push( $(this).val() ); });
    
            // debug output
            alert( values.join("\n") ); 
            //submit the form 
        } 
    });
    

提交回复
热议问题