[英]Jquery serivalize doesn't work. Names are given
I want to get serialized string from all my checkboxes. 我想从所有复选框中获取序列化的字符串。 Trying to do it this way.
尝试以这种方式进行。
var companies=$("input.company").serialize();
console.log($("input.company").serialize());
alert(companies);
Here is my html form. 这是我的html表格。
<div id="listOfCompanies"><h1>Список компаний</h1>
<input type="checkbox" class="company" name="company" value="Microsoft">Microsoft<br>
<input type="checkbox" class="company" name="company" value="Apple">Apple<br>
<input type="checkbox" class="company" name="company" value="Ubisoft">Ubisoft<br>
<input type="checkbox" class="company" name="company" value="sony">sony<br><input type="checkbox" class="company" name="company" value="agilient_technology">agilient_technology<br>
<input type="checkbox" class="company" name="company" value="marvel">marvel<br>
<input type="checkbox" class="company" name="company" value="blizzard">blizzard<br>
<input type="checkbox" class="company" name="company" value="ibm">ibm<br>
</div>
Both console and alert give empty string. 控制台和警报均提供空字符串。 Any suggestions?
有什么建议么?
Unchecked checkboxes aren't included by the browser, which makes sense really because they have a boolean state -- they're either selected by the user (included) or not selected by the user (not included). 未选中的复选框未包含在浏览器中,这确实是有道理的,因为它们具有布尔状态-由用户选择(包含)或未被用户选择(未包含)。
alert($("input.company").prop('checked', true).serialize());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.