Hi

I'm working on news excerpts and I want to hide everything to just title,
then create trigger element and switch between excerpts.

The HTML structure:

<div class="headers">
        <div class="thumbTiny">
                     
                <h4>  Title </h4>
                <p>News excerpt desc.</p>
        </div>
        <div class="thumbTiny">
                ...
        </div>
        ... (3 more div.thumbTiny)
</div>
<div class="headers">
        ... (another div.headers, few times)
</div>

I prepared classname - "thumbHidden", which - when applied to div.thumbTiny
- hides image and paragraph.

Then jQuery script:

$().ready(function() {

        $.each($('#main .headers'), function(i) {

                this.id = 'header' + i;
                var selector = '#header' + i + ' .thumbTiny';
                $(selector).addClass('thumbHidden');
                $(selector).prepend('<span class="showNews">[+]</span>');
                $(selector + ':first').removeClass('thumbHidden');
                $(selector + ' .showNews').click(function() {
                        $(selector + ' 
.showNews').parent().removeClass('thumbHidden');
                });//click

        });//each

});//document

Problem is with 

$(selector + ' .showNews').click(function() {
        $(selector + ' .showNews').parent().removeClass('thumbHidden');
});

I tried many options, even attaching events outside the $.each using general
$('span.showNews') selector. Simple click, bind("click"… all fail. 

When I write in Firebug inline
onclick="$(this).parent().removeClass('thumbHidden')" it works, class is
removed and my excerpt is shown. 

What am I doing wrong?
-- 
View this message in context: 
http://www.nabble.com/Event-attaching-fail-tf2840123.html#a7929325
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to