最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery: The input element's type does not support selection - Stack Overflow

programmeradmin3浏览0评论

I'm trying to send a form via AJAX, using jQuery. But I got the error when clicking the submitting button (it is actually a link, but doen't matter).

That's the error in the console:

Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('checkbox') does not support selection.

I suspect the problem is that I have some checkboxes there with a multiple selection, and they've been parsed like this:

var logo = $('input[name=extra]:checked');

I've tried to stringify them, so it looked like: var logo = JSON.stringify($('input[name=extra]:checked')); but it didn't seem to fix the problem.

What can be the reason or am I doing something wrong?

UPD: jsFiddle here

I'm trying to send a form via AJAX, using jQuery. But I got the error when clicking the submitting button (it is actually a link, but doen't matter).

That's the error in the console:

Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('checkbox') does not support selection.

I suspect the problem is that I have some checkboxes there with a multiple selection, and they've been parsed like this:

var logo = $('input[name=extra]:checked');

I've tried to stringify them, so it looked like: var logo = JSON.stringify($('input[name=extra]:checked')); but it didn't seem to fix the problem.

What can be the reason or am I doing something wrong?

UPD: jsFiddle here

Share Improve this question edited Sep 8, 2014 at 9:40 Artem Ushakov asked Sep 8, 2014 at 9:15 Artem UshakovArtem Ushakov 3132 silver badges13 bronze badges 5
  • Since you activate the form submission by clicking on a link, I assume that you handle the form submission with javascript... Care to share that piece of code here so we can help you? – Loupax Commented Sep 8, 2014 at 9:26
  • jsfiddle would help here – artm Commented Sep 8, 2014 at 9:28
  • You are getting a list of elements, I suspect you want to get their values. – Rob Schmuecker Commented Sep 8, 2014 at 9:35
  • And that's my link – Artem Ushakov Commented Sep 8, 2014 at 9:39
  • var word1 = $('input[name=line1]:checked').val();? – Arun P Johny Commented Sep 8, 2014 at 9:45
Add a ment  | 

2 Answers 2

Reset to default 5

You have to get the value with the val() method:

$('input[name="line1"]:checked').val()

I updated your snippet here: http://jsfiddle/4mxsvch3/2/

Try this

  $('input[name="extra"]').is(":checked");
发布评论

评论列表(0)

  1. 暂无评论