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:
    768
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #2
    NVM, found it.

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