SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict tlacaelelrl's Avatar
    Join Date
    Apr 2011
    Location
    Mexico city, Mexico
    Posts
    353
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    JQuery, set class to elements in Array

    Hello everyone!

    I have this function

    Code:
    var tdM = new Array($('#todoMessageArea'), $('#todoMessageArea2'));
    var tdMC = new Array('errorM', 'successM');
    function setAlertMessage ( message, suc ) {
    	tdM.each(function(el){
    		el.addClass(tdMC[suc]);
    		el.fadeIn('slow', function() {
    			el.html(message);
    		});
    		setTimeout(function(){
    			el.fadeOut().delay(3000);
    			el.html('');
    			el.removeClass(tdMC[suc]);
    		}, 10000);
    	});
    }
    For the 2 Arrays, the first holds two paragraphs and the second class names to be applied, in the function the first parameter is a message and the second an integer, when I call the function nothing happens and also no errors are displayed in firebug, is it not possible to handle things the way I am doing or do I have to do it some other way?
    Do you get bothered because I do the same thing every day?
    Do you question why I do it?
    Then find something that you actually like doing!!!

    Stop thinking on what I do.

  2. #2
    SitePoint Addict tlacaelelrl's Avatar
    Join Date
    Apr 2011
    Location
    Mexico city, Mexico
    Posts
    353
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Never mind, I was putting the function and variables before the document was loaded!
    Do you get bothered because I do the same thing every day?
    Do you question why I do it?
    Then find something that you actually like doing!!!

    Stop thinking on what I do.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •