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 7574605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:28:33+00:00 2026-05-30T16:28:33+00:00

var btnid=0; function show_visited_stops(bus_stops_visited,map){ var $k=0; var visited_bus=; var total_time=0; visited_bus=<table border=\1\>; while($k<bus_stops_visited.length){ $A=bus_stops_visited[$k];

  • 0
var btnid=0;
function show_visited_stops(bus_stops_visited,map){


                var $k=0;
                var visited_bus="";
                var total_time=0;
                visited_bus="<table border=\"1\">";
                while($k<bus_stops_visited.length){

                $A=bus_stops_visited[$k];

                if ($k==bus_stops_visited.length-1){
                var latlng=findlatlng($A);
                var name=find_stop_name($A);
                btnid++;
                var btn_id="btn"+btnid;
                visited_bus+="<tr><td><button id="+btn_id+" class=\"linked\">"+name+"</button></td>"+ "<td>"+"Time taken:"+total_time.toFixed(2) +'min'+ "</td></tr>";
                var c="#"+btn_id;
                $(c).on("click", function(event){
                    alert("DSD");
                });

                    break;
                }
                $k=$k+1;
                $B=bus_stops_visited[$k];

                var name=find_stop_name($A);
                btnid++;
                var btn_id="btn"+btnid;
                visited_bus+="<tr><td><button id="+btn_id+" class=\"linked\">"+name+"</button></td>"+ "<td>"+"Time taken:"+total_time.toFixed(2) +'min'+ "</td></tr>";
                var c="#"+btn_id;
                $(c).on("click", function(event){
                    alert("DSD");
                });



                total_time+=parseFloat(find_edge_weight($A,$B));



            //  alert("edge traversed"+edge_traversed);
        }
        visited_bus+="</table>"; 

        alert(visited_bus);
        return visited_bus;
}

I want each button generated to have a click event attached to it. But its not working. I also tried .click() .bind() its not working either.

Any suggestions. I’m stucked
What i want is when each button is clicked, the alert should be fired. (i will replace the alert with another function).

UPDATE:
I got the solution:
i’ve used

$(document).on("click", c, function(){ alert("Goodbye!"); });
  • 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-30T16:28:34+00:00Added an answer on May 30, 2026 at 4:28 pm

    Follow the below steps,

    Step 1: In the function show_visited_stops change the below line,

    visited_bus="<table border=\"1\">";
    

    to

    visited_bus="<table border=\"1\" class=\"visited_stops_tbl\">";
    

    Step 2: Implement the .on method in below syntax,

    $('.visited_stops_tbl').on ('click', '.linked', function () {
       //btn click function
    })
    

    Step 3: Add the Step 2 code in place just after the table is inserted.

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

Sidebar

Related Questions

var geocoder, map, point, fmtAdd, marker; function mapLoad() { geocoder = new google.maps.Geocoder(); var
var ref1 = new Firebase(http://gamma.firebase.com/myuser/123,456); ref1.set(123,456); var on1 = ref1.on(value, function(snapshot) { console.log(snapshot.val()); });
var Foo = Foo || {}; Foo.Controller = (function ($) { var $page =
var JavascriptHelper = Backbone.Model.extend(JavascriptHelper, {}, // never initialized as an instance { myFn: function()
var messageSpan; function createFlashMessage = function(message, type, time) { messageSpan || (messageSpan = $(<span>).hide().appendTo(body));
this is the JS <SCRIPT type=text/javascript> $(function() { var ids = new Array(); for(var
I have this function: function addButtonLookup() { var element = document.getElementById(btnToolBar); var index; for
var UsersMenu = function(){ this.returnUsers = []; this.retrieve = function(posts){ var temp = [];
Have next script: function clicker(){ var linkId = [id*= + link]; var butnId='initial'; $j(linkId).click(function(){
var h=0; var w=0; $(.extend).hover(function() { //alert(h); $(this).css({'z-index' : '999' }); $(this).addClass(hover).filter(:not(:animated)).stop() .animate({ marginTop:

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.