Reputation: 9
<?php $q=mysql_query("select * from comments);
While($r=mysql_fetch_array($q))
{?>
One button and A textbox here for when i click the button then the textbox will show up.. And this is the loop section,,, and this work is to be done with jquery,,
$(".button").click(function(){
$(".textbox").show();
});
After execution of code! I have 10buttons that is created by loop contruct with php while... When i click ones the button to show the textbox.. All buttons are clicked at same time,, and all textbox are shown at same time automatically,, why? So wht should i do guyz?
Upvotes: 0
Views: 30
Reputation: 1689
if you have multiple rows and each row has a button and textbox and all of them have .button and .textbox classes then you have to write your jQuery code little differently.
$(".button").click(function(){
$(this).closest(".textbox").show();
});
The thing is that in your code click on any element with class .button will result in showing all the elements with .textbox class. In modified version when you click button then we are using $(this) to address exactly the button that was clicked and then searching for the textbox closest to this particular button. But it depends on your html structure.
Upvotes: 1