0

Well I don't know correct word for this so I wrote three of them, hope you wont mind...

Now, my question. I have javascript that is running on pageload as it's usual... The script hide specified id's and reveal them on click. Let's call this script "hide on load".

My problem here is, that another javascript, let's call it "news" is running as well on page load and I can see it only 1 second, until another script hide div id's.

Once I click on specified div that should run reveal "news", nothing happends. I can see that "hide on load" running fading (fadein) but nothing is being revealed.

Hide on Load script:

$(window).load(function(){
var activeElement;

function activateElement( eltSuffix ) {
    if( activeElement ) {
        activeElement.fadeOut( 500, function() {
            activeElement = $('#content-reveal-'+eltSuffix);
            activeElement.fadeIn( 500 );
        } );
    } else {
        activeElement = $('#content-reveal-'+eltSuffix);
        activeElement.fadeIn( 500 );
    }
}

$(document).ready( function() {
    $('#content div').hide();
    $('#info a').click( function() {
        activateElement('info');
    } );
    $('#search a').click( function() {
        activateElement('search');
    } );
    $('#music a').click( function() {
        activateElement('music');
    } );
    $('#socials a').click( function() {
        activateElement('socials');
    } );
} );
});

News script:

    $(document).ready(function () {
        $('#newsticker_1').newsticker({
            'style': 'fade',
            'showControls': false,
            'autoStart': true,
            'fadeOutSpeed': 'slow',
            'fadeInSpeed': 'slow',
            'transitionSpeed': '4000',
            'pauseOnHover': true
        });
})(jQuery);

Thank you!

4

1 回答 1

1

You can use onclick html on the div so....

<div id="whatyouwanttoclickon" onclick="news()"></div>

But you would have to name the function news like this.

function news(){
        $('#newsticker_1').newsticker({
            'style': 'fade',
            'showControls': false,
            'autoStart': true,
            'fadeOutSpeed': 'slow',
            'fadeInSpeed': 'slow',
            'transitionSpeed': '4000',
            'pauseOnHover': true
        });

Or you could use jquery like this....

$('#divyouwanttoclickon').click(function(){//putyourfunctioninhere});
于 2012-05-15T10:31:33.397 回答