Hello,
I have an event ('show' & 'click') bounded to the element to make it scrollable using the jquery '.on' method but when I try to bind another event on click like below the alert does not show up -

$('.elem').on('show', function(){//some code here}).on('click', function(){alert($(this).text())});

what I am actually trying to do is, leave this 'tr' hidden initially and while pn click of it make it visible.
But its not happening clearly.Thank you

Recommended Answers

All 2 Replies

Do you have a more complete code sample that we can work with?

what I am actually trying to do is, leave this 'tr' hidden initially and while pn click of it make it visible.

Ok so why not initially set the CSS display:none on this tr element, and just do something like this...

$('elem').click(function(){
   $('tr').show();
});

Thank you for your reply.
I am doing the similar thing like hiding the element at first and then trying to show it on click or the scrollable event. but if the element is hidden initially they jquery code above, set up on '.on' dont work. It also leaves empty space between two rows.

<script>
$('.accordion .collapse')
                        .on('show', function() {
//                                alert($(this).attr('id')+'>>');
//                                console.log($(this).attr('id'));
//                                $($(this).attr('id')).attr('display') = 'table-row';

                            $(this).prev('.accordion-heading').find('.accordion-toggle').addClass('in');

//                                    css('background-color', 'red');
//                                    .find('row_collapse0').addClass('disp');
                        })
                        .on('click', function(){alert('test')})
                        .on('hide', function() {
</script>

<tr id="row_collapse'.$i.'" style="display:inline; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; border:0px solid red;">
                            <td colspan="9" style="margin-left:25px; max-height:2px;" >
                                <div id="collapse'.$i.'" class="accordion-body collapse">
                                <div id=" class="accordion-inner">
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.