0
votes

it is strange!

when i create a dynamic input(checkbox type), i can control checked is true or false, but when i create it with disable default, it sets input to checked!

here is my code:

var theInput = new $('<input>', {
  id: 'myCheckbox',
  name: 'myCheckbox',
  type: "checkbox",
  disabled: true,
  checked: false
});
theInput.uniform();

it adds disabled but checked input,

var theInput = new $('<input>', {
  id: 'myCheckbox',
  name: 'myCheckbox',
  type: "checkbox",
  disabled: true,
  checked: true
});
theInput.uniform();

if i set checked to true, then it adds disabled and unchecked input why?

i changed "checked" to checked, but there is no diffrence.

i complete my code, problem is in uniform, when i uniform it, it changed property!

1
did you try to change "checked" to checked - Manish Jangir
Both versions do what they should do for me in Google Chrome. What browser are you using? - Chris
why is "checked" a string? checked:true should work just fine - PlantTheIdea
@Manish Jangir Blogaddition.com no diffrence - user2928818
@Chris you are right thank you problem was in uniform, let me check why. - user2928818

1 Answers

0
votes

I just created a fiddle. Please check might help you. This is working. You can check this by changing checked to true or false in the fiddle.

http://jsfiddle.net/Wc78K/1/

$(document).ready(function(){
    $('#containerId')
    .append(
       $(document.createElement('input')).attr({
           id:    'myCheckbox'
          ,name:  'myCheckbox'
          ,value: 'myValue'
          ,type:  'checkbox'
          ,disabled: true
          ,checked: true
       })
    );
});