jQuery - Fetching ID names

by 2 replies
3
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!

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

Next Topics on Trending Feed

  • 3

    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! Code: $("#cfirst").click(function () { if ($("#first").is(":hidden")) { if( == "250px") { var = 1000; //animate bar $("#main").click(function(){ $(this).animate({"top": "50px"}, 1000 ); var = "50px"; }); } if($("#second, #third").is(":visible")) { $("#second, #third").slideUp("1000"); var = 500; } $("#first").delay().slideDown("1000"); } });