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

  • SEARCH
  • Home
  • 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 9202091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:10:30+00:00 2026-06-17T23:10:30+00:00

I am having an issue with the .toggle() function that I am using. I

  • 0

I am having an issue with the .toggle() function that I am using. I am getting results from a database using PHP and filling a table with the information. The last item in each table row is a link, that when clicked should show another row that allows an admin to edit the information for that product. The link’s class is .edit_prod Here is my jQuery method:

$(function() {
$(".edit_prod").click(function() {
 $("#mydiv").toggle();
      return false;
     });
 });

Can someone help me out on what could possibly be going wrong?

Thanks!

Update:

Here is the PHP code which creates the HTML

$table_format = sprintf("
        <tr>
            <td>
                <img src='%s' id='edit_img_pic' />
            </td>
            <td>
                %s
            </td>
            <td>
                %s
            </td>
            <td>
                <a class='edit_prod' href='#'>Edit</a>  
            </td>



        </tr>
        <tr id='mydiv' style='display: none' cellspacing='20px'>
            <form action='edit_product.php' method='post'>
            <td>
                <label for='name'>Product Name</label><br>
                <input type='text' name='name' value='%s' /><br><br>
            </td>
            <td>
                <label for='sku'>SKU</label><br>
                <input type='text' name='sku' value='%s' /><br><br>
            </td>
            <td>
                <label for='price'>Price</label><br>
                $<input type='text' name='price' value='%s' /><br><br>
            </td>
            <td>
                <label for='desc'>Description</label><br>
                <textarea cols='40' rows='7' name='desc'></textarea><br><br>
                <input type='submit' value='Save' />
            </form>
        <tr>
        ", $img, $prod_name, $sku, $prod_name, $sku, $price);

        echo $table_format;

Update 2:

  • 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-06-17T23:10:31+00:00Added an answer on June 17, 2026 at 11:10 pm

    According to your last sentence

    each table row is a link, that when clicked should show another row
    that allows an admin to edit the information

    Seems that you are dynamically loading elements to your html, that way the new elements have no click event attached to them because you probably attach it on document.Ready()..

    jQuery has a “on” API that you could use to attach click events to DOM elements loaded dynamically.

    EDIT
    Thanks to @rockerest.. changed from using live() to on() and corrected according to @Sly_cardinal.

    Try something like that:

    $(function() {
        $("table").on("click", ".edit_prod", function() {
            $("#mydiv").toggle();
            return false;
        });
    });
    

    jQuery on API Documentation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue with a control I'm building that contains a table where
I'm having an issue with my toggle function combined with the slide effect. I
I having issue that content assistant / intellisense is working in methods such as
Hi guys I am having issue I have this query: SELECT * FROM useraccount
Having an issue here that I have tried everything I can think of but
I am having an issue with bootstrap input text height size. I am using
I am having trouble resolving an issue using traditional JavaScript and was wondering if
I am having an issue with some Jquery script that I have and I
I'm having issues showing an image that is hidden using jQuery. I have hidden
I am having an issue combining two functions that work independently correctly, was hoping

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.