How to remove this cookie?

I am creating a cookie, but I need to remove A cookie based on a onclick event that I am trying to set, but is not working.

Here is how I am setting the cookie. Which works fine.

 <script type="text/javascript">//<![CDATA[
 $(window).load(function(){
 $(".filter input").each(function() {
     var mycookie = $.cookie($(this).attr('name'));
     if (mycookie && mycookie == "true") {
         $(this).prop('checked', mycookie);
     }
 });
 $(".filter input").change(function() {
     $.cookie($(this).attr("name"), $(this).prop('checked'), {
         path: '/',
         expires: 365
     });
 });

 });//]]>  

And then to delete I am trying to remove the cookie on click event based on an ID with out any luck, I am just not sure where I am going wrong here, would this work… ??? $.removecookie($(this).attr(‘name’), null, { path: ‘/’ }); see my code below.

 <script>
    jQuery('#dnn_ctr555_ProductSearch_rpData_cmdAdvReset_0').click(function()  {
          $.removeCookie($(this).attr('name'), { path: '/' });
     }
</script>

Here is a fiddle http://jsfiddle.net/23nUZ/ any help would be awesome.

Hi,

Welcome to the forums :slight_smile:

Your ids are very verbose and make the code hard to read.
Are you choosing them yourself or are they being generated by something?

Anyway, if you indent and organize your code correctly (which is as easy as pressing the “Tidy Up” button in JSFiddle), you’ll see that this:

//remove cookie on click.
jQuery('#dnn_ctr555_ProductSearch_rpData_cmdAdvReset_0').click(function()  {
        $.removeCookie($(this).attr('name'), { path: '/' });
      }

becomes this:

//remove cookie on click.
jQuery('#dnn_ctr555_ProductSearch_rpData_cmdAdvReset_0').click(function () {
    $.removeCookie($(this).attr('name'), {
        path: '/'
    });
}

and it becomes much easier to notice the missing bracket and semi-colon:

//remove cookie on click.
jQuery('#dnn_ctr555_ProductSearch_rpData_cmdAdvReset_0').click(function () {
    $.removeCookie($(this).attr('name'), {
        path: '/'
    });
}[B]);[/B]  [B][COLOR="#FF0000"]<---- here[/COLOR][/B]

Also, is there any reason you switch at random from using the dollar alias to using jQuery?