0

假设 a,b,c 结果是通过回 显$scname变量从数据库动态生成的,并showtablesconclick. a,b ,c但是除了第一次点击之外,当我点击任何结果时,表单上的发送按钮似乎总是被预先点击。

我的 PHP 代码在这里:

   echo "<a  href='#$name' style='margin-left: 30px' onclick=showtablesc();>$scname</a><br>";

html在这里..

 <table id="jobs" style="display:none"  bgcolor="#0099FF" align="center"

     <tr  ><td> j tittle</td><td><input type="text" name="tittle" /></td></tr>
     <tr ><td><input type='button' value='send'  id="send"  /></td> </tr>
    </table>

jquery函数在这里

function showtablesc(){

$('#jobs').show('fast');
$('#send').click(function(){
    $('#send').replaceWith("<em>sending...</em>");

    });

}

4

3 回答 3

1

似乎您的 tr 具有“工作”类,而您的按钮则具有。这意味着 JQuery 将对两者都执行单击,并且您的 tr 是第一个处理它的。

于 2012-09-20T05:01:09.387 回答
0
echo "<a  href=\"#$name\" class=\"my-link\" style=\"margin-left: 30px\">$scname</a><br />";

$(document).ready(function(){

    $('a.my-link').click(function(){
        $('#jobs').show('fast').find('em').replaceWith('<input type="button" value="Send" class="jobs" />');
    });

    $('#jobs').on('click','input.jobs',function(){   
        $(this).replaceWith("<em>sending...</em>");   
    });   

});
于 2012-09-20T05:21:42.327 回答
0

将您的HTML块更改为此

<table id="jobs_table" style="display:none"  bgcolor="#0099FF" align="center">

 <tr class="jobs" >
    <td> j tittle</td>
    <td><input type="text" name="tittle" /></td>
 </tr>
 <tr >
    <td><input type='button' value='send'  class="jobs_button"/></td> 
 </tr>
</table>

而你Jquery

function showtablesc(){
   $('.jobs_button').removeAttr("id");

   $('.jobs_button').attr('id', 'send');
   $('#jobs_table').show('fast');
   $('#send').click(function(){
       $('#send').replaceWith("<em>sending...</em>");
   });
}
于 2012-09-20T05:22:46.550 回答