www.webdeveloper.com
Results 1 to 3 of 3

Thread: How can I hide a variable with JQuery?

  1. #1
    Join Date
    Mar 2012
    Posts
    6

    Question How can I hide a variable with JQuery?

    Hi,

    I'm a newboy with JQuery and AJAX so hopefully the question isn't too stupid ........

    I'm trying to hide a few spann classes with has a variable class hide_record_xxxx. Hiding a ID or class isn't a problem but how do I call a variable in the hide function?

    Code:
    <script type="text/javascript">
    $(document).ready(function(){
     $("body").on("click", ".delbutton", function() {
    	var id = $(this).attr("id");
    	var dataString = 'id='+ id;
    	var parent = $(this).parent();
    	var hide_record = 'hide_record_'+ id;
    	// alert(dataString);
    	alert(hide_record);
    	if(confirm("Weet u zeker dat u dit onderdeel wilt verwijderen?")) {
    		$.ajax({
    			type: "POST",
    			url: "toernooi-onderdelen-verwijderen-ajax.php",
    			data: dataString,
    			cache: false,
    			success: function(){
    		  	parent.fadeOut('fast', function() {$(this).remove();});
    				alert(hide_record);
    				
    				$(+hide_record).hide();
    				//$(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
    				//.animate({ opacity: "hide" }, "slow");
    			}
    		});
    		// $(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
    		// .animate({ opacity: "hide" }, "slow");
    	}
    	return false;
    	});
    });
    </script>
    The var hide_record is giving me the right alert but how make I this class to hide?

    Kind regards,

    Arie

  2. #2
    Join Date
    Feb 2012
    Location
    Tallahassee, FL
    Posts
    280
    If I am understanding you correctly, the following should do what you need.

    For a class:
    Code:
    $("."+hide_record).hide();
    For an id:
    Code:
    $("#"+hide_record).hide();

  3. #3
    Join Date
    Mar 2012
    Posts
    6
    Tnx a lot, it's working now!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles