1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.
  2. Better Analytics for WordPress Get It Free

Fetching ID names?

Discussion in 'jQuery' started by almondj, Jan 23, 2012.

  1. #1
    Here's the situation I have a div that has animation. I want to use this animation on other divs. What I'm trying to figure out is how to get the actual ID name of the element that was clicked. For example, if '#id1' was clicked, then I would like '#id1' as a var. Anyway to do this? Thanks all!

    $("#cfirst").click(function () {
    if ($("#first").is(":hidden")) {
    	if($pos == "250px") {
    	  var $delay = 1000;
    	  //animate bar
    	  $("#main").click(function(){
    	    $(this).animate({"top": "50px"}, 1000 );
    	    var $pos = "50px";
    		});
    	  }
    	if($("#second, #third").is(":visible")) {
    	$("#second, #third").slideUp("1000");
    	var $delay = 500;
    	}
    	$("#first").delay($delay).slideDown("1000");
    }
    });
    Code (markup):

     
    almondj, Jan 23, 2012 IP
  2. almondj

    almondj Peon

    Messages:
    770
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #2
    NVM, found it.

    var idName = this.id
    Code (markup):
     
    almondj, Jan 23, 2012 IP