CodeCanyon

Simple checkbox question

708 posts
  • Belgium
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 100 and 1 000 dollars
Yaeko says

Hi,

Here’s a simple question. I have a checkbox, so as we all know, when you click on it, it is checked.

Here’s the thing, when you check it, it doesn’t update the DOM , you can see that it’s checked, but not in the DOM . So I tried to add the attribute “checked = checked” to the element via JS, but it doesn’t change a bit.

Anyone else has saw this “issue”? I need the checked attribute for further processing since I’m taking the innerHTML of the parent to put it into another “div” after a click event.

Thanks!

1746 posts
  • Microlancer Beta Tester
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 3-4 years
  • Austria
  • Exclusive Author
  • Referred between 200 and 499 users
+2 more
revaxarts says

can you submit a snippet to jsfiddle?

708 posts
  • Belgium
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 100 and 1 000 dollars
Yaeko says

yeah sure: jsfiddle

123 posts
  • Exclusive Author
  • Has been a member for 1-2 years
  • Sold between 100 and 1 000 dollars
  • United Kingdom
matt5409 says

I’m not sure I understand… if you’re posting it to another page, the value is passed on submit. Alternatively if you need it to affect the DOM , just use JS. Something like http://forum.jquery.com/topic/jquery-checkbox-checked-event ?

708 posts
  • Belgium
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 100 and 1 000 dollars
Yaeko says

The DOM needs to be changed when you check the checkbox. I’m trying it to do it with JS, but it doesn’t change a bit in the DOM .

1746 posts
  • Microlancer Beta Tester
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 3-4 years
  • Austria
  • Exclusive Author
  • Referred between 200 and 499 users
+2 more
revaxarts says

Don’t get it. With jQuery everything seems normal: http://jsfiddle.net/zaSVH/1/

708 posts
  • Belgium
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 100 and 1 000 dollars
Yaeko says

check the checkbox and inspect the element, you’ll see that the attribute “checked” isn’t there but the checkbox is checked.

1746 posts
  • Microlancer Beta Tester
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 3-4 years
  • Austria
  • Exclusive Author
  • Referred between 200 and 499 users
+2 more
revaxarts says

I guess because “checked” is not an attribute rather a property. You write checked="checked" because of a valid XHTML syntax. HTML don’t need that so checked is good.

readonly, disabled or required are also properties and not attributes

Edit: properties can only be true or false not something like “checked”

2980 posts
  • Community Superstar
  • Has been a member for 5-6 years
  • Won a Competition
  • Sold between 50 000 and 100 000 dollars
  • Bought between 10 and 49 items
  • Referred between 50 and 99 users
  • Europe
+1 more
wickedpixel says

What is the value of an input that is checked and not checked?

by
by
by
by
by