tags:

views:

31

answers:

2

i want to make a single submission with dynamic jquery script but it doesn't worked what wrong with my code?

$(document).ready(function(){

   $("#foo").each( function( i )
   {

        $("button#foo").eq(i).click(function()
            {
               var a = this.val();
               alert(a);
            });
   });

});

<div id="tabs-1"><input type="type" value="one"><button id="foo"></button></div>

<div id="tabs-2"><input type="type" value="two"><button id="foo"></button></div>

<div id="tabs-3"><input type="type" value="tree"><button id="foo"></button></div>

thanks mapet

+1  A: 

The problem is you are repeating IDs. IDs have to be unique. Also what you're doing doesn't make a lot of sense. What are you trying to achieve?

cletus
i have tab with the different content i want it to dynamic so that my code will not be redundant.. like.. $("#foo1").click( function() { content ... 1 });$("#foo2").click( function() { content ...2 });$("#foo3").click( function() { content ...2 });
mapet
+2  A: 
rahul
but rahul how i determine that click button.1 or 2? if(click button1){ ajax get;}else{ ajax get 2;}
mapet
Edited my answer
rahul
you gotta it.. rahul thanks alot ^^
mapet