Question

i have a problem with jquery. I have a simple tab and accordions combo in jquery easy ui, tabs and accordion as a children div.

The data of accordion and tabs are read prom php arrays. I made a quick sneak peak of the html code below and fiddle

<div class="labels"><span></span> </div>
    <div id='easyui-tabs' style=" background: white;">
        <div id="tab1" title="1" style="padding:5px;">
            <div class="easyui-accordion">
                <div class="subgroup" title="1">
                   <p><input type="checkbox" value=""/><label><b class="b_1">test1</b></label></p>
                </div>
                <div class="subgroup" title="1">
                   <p><input type="checkbox" value=""/><label><b class="b_2">test2</b></label></p>
                </div>
                <div class="subgroup" title="1">
                   <p><input type="checkbox" value=""/><label><b class="b_3">test3</b></label></p>
                </div>
            </div>
        </div>
        <div id="tab2" title="2" style="padding:5px;">
            <div class="easyui-accordion">
                <div class="subgroup" title="1">
                   <p><input type="checkbox" value=""/><label><b class="b_1">test1</b></label></p>
                </div>
                <div class="subgroup" title="1">
                   <p><input type="checkbox" value=""/><label><b class="b_2">test2</b></label></p>
                </div>
            </div>
        </div>
    </div>

JS

$(document).ready(function() {
            $('.easyui-accordion').accordion({
                animate: true,
                fit: true
            });
            $('#easyui-tabs').tabs({
                tabPosition: 'left',
                headerWidth: '80'
            });
        });

http://jsfiddle.net/msx20/cf5ju/19/

And i want to display the labels values by trigger checkbox for current label show/hide label values (dynamicly) in the "labels" div above separeted by comma.

The labels and inputs gonna have diferent classes.

I try to use click(function() and .val but i didnt work at all.

Can anyone help me with this simple thing please(i suppose ,for enyone who knows jquery)

Was it helpful?

Solution

You can just add a change handler for the checkbox like

$('#easyui-tabs input[type=checkbox]').change(function(){
    $(this).next().toggle(this.checked)
}).change()

Demo: Fiddle

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top