Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5940867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:01:44+00:00 2026-05-22T16:01:44+00:00

I have this link: <%= link_to_function remove, remove_fields(this)%> which outputs this html: <a href=#

  • 0

I have this link:

<%= link_to_function "remove", "remove_fields(this)"%>

which outputs this html:

<a href="#" onclick="remove_fields(this); return false;">remove</a>

and I have this JQuery function:

    function remove_fields(link){
      $(link).prev("input[type=hidden]").val("1");
      $(link).closest(".fields").hide();
    }

but when I click on the link, I get this error:

Uncaught ReferenceError: remove_fields is not defined

Why is this and how do I fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:01:45+00:00Added an answer on May 22, 2026 at 4:01 pm

    You should not use the onclick attribute, it’s a bad practice and something that belongs back in the 90s. Instead you should add a class for your anchors and bind a handler to the click event with jQuery.

    HTML

    <a class="remove-fields" href="#">remove</a>
    

    JavaScript

    // This is a shorthand for document.ready
    $(function(){
        // Bind handler to click event
        $("a.remove-fields").click(function(e){
            var $this = $(this);
            $this.prev("input[type=hidden]").val("1");
            $this.closest(".fields").hide();
            // Prevent default behavior
            e.preventDefault();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have link that calls a function when clicked: <a href=javascript:spawnMenu(this); id=link1>Test1</a> To make
I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.
i have a DTD file which i used to accessed through this link: http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd
I have this hidden link, which is needed for other purposes: <span id=notitle style=display:
I am having issues getting my remove element function working. I have this function:
I have this line below that shows a link to go the next page
i need to create a chart similar to this: link text Do you have
I have a link to some style sheet from the Yahoo Developer Network, this
I have a ChildWindow. In this childwindow, I have added properties that link to
Similar to this question: link However I have already mastered that. My problem is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.