开发者

how to add that classname(to refer plugin) to the checkboxes while creating dynamically?

I am working with JavaScript and Jquery Application. In that, I have created a checkbox dynamically by using the following codings开发者_开发百科...`

//this function called from a for loop and will get name, j values from XML and create checkbox with that name...

function append(name,j)       
         {                
            var cb = document.createElement( "input" );
            cb.type = "checkbox";
            cb.id = "id";
            cb.value = "test";
            cb.checked = false;
            cb.className='checkbox_container';
            var text = document.createTextNode( name );
            document.getElementById( 'append' ).appendChild( cb ); 
            document.getElementById( 'append' ).appendChild( text );
     }

Also, this created checkbox will display in DiV below,

<div class="checkbox_container" id="append">      </div>

Here Class=checkbox_container is used for serchbox plugin....

I have tried the above method using static checkboxes like ...

<div class="checkbox_container"><img src="11.jpeg" width="30" height="30">&nbsp;&nbsp;<input type="checkbox" /><span>Nandha</span></div>
        <div class="checkbox_container"><img src="12.jpeg" width="30" height="30">&nbsp;&nbsp;<input type="checkbox" /><span>Senthil</span></div>

If i create these check box statically, the checkbox_container class refers plugin and display the suggestions in the search box.....but if i create dynamic chack box..it is not display suggestions...

My question is , how to add that classname(to refer plugin) to the checkboxes while creating dynamically????.... please help me...


You need to call the code to initialise the plugin after the checkboxes are created.


If you are using Mozilla then you should use cb.class instead of cb.className.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜