Jquery无法从joomla中的文本框中获取值

时间:2011-07-06 02:13:34

标签: jquery joomla

jQuery无法从Joomla的文本框中获取价值,我正在使用 脚本如下:

<?php JHTML::_('behavior.jquery'); ?>
<script>
    jQuery.noConflict();
    jQuery(function(){

            jQuery("#register").click(function(){


                alert($("#txtusername").val());

            });


    });

</script>

<form name="frm1" id="frm1" method="get">
    <table border="0" style="width:100%;">
        <tr>
            <th colspan="2" align="center">Register</th>
        </tr>
        <tr>
            <td align="right">Username:</td>
            <td><input type="text" name="txtusername" id="txtusername"/></td>     
       </tr>
        <tr>
            <td align="right">Password:</td>
            <td><input type="text" name="txtpassword" id="txtpassword"/></td>
        </tr>
        <tr>
            <td colspan="2">&nbsp;</td>
        </tr>
        <tr><td>&nbsp;</td><td><input type="button" id="register" value="register"/></td></tr>
        <tr>
            <td colspan="2">


            </td>
        </tr>
    </table>
</form>

1 个答案:

答案 0 :(得分:2)

使用jQuery.noConflict()时。你不能使用$

您正在使用$

提醒您注意价值
alert($("#txtusername").val());

将其更改为

 alert(jQuery("#txtusername").val());

查看此工作example

相关问题