<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<script src="http://dev.jquery.com/view/trunk/plugins/color/jquery.color.js"></script>
<!--这里链接的是网上的jquery.js 所以网页显示的速度很慢-->
<script type="text/javascript">  
function $(el){return document.getElementById(el)};  function response(obj)  
{
var oComment=obj.parentNode;
oComment.appendChild($("response"));  
$("response").style.display="block";} $(document).ready(function(){
$("#add").click(function(){
alert('fffffffffffffff');   
})
})
</script><div>
<div> xxxxxxxxxxxxxxxxxx
  <div onClick="response(this);" style="color:red;cursor:pointer;">回复 </div>
</div>
<div> xxxxxxxxxxxxxxxxxx
  <div onClick="response(this);" style="color:red;cursor:pointer;">回复 </div>
</div>
<div id="response" style="display:none;">
  <textarea style="width:300px;height:150px"> </textarea>
  <p>
    <input value="提交" type="submit" id="add"/>
</div>
</body>
</html>问题:为何点击提交没有执行alert('fffffffffffffff');谢谢!

解决方案 »

  1.   

    $是JQuery中的一个对象,其实也是一个function.
    你定义了function $(el){return document.getElementById(el)};
    把JQuery中的$()覆盖了。
    你可以试试JQuery("#add")").click(function(){
    alert('fffffffffffffff');   
    })或者在$("#add").click()之前加一句 $ = JQuery;
      

  2.   

    干嘛把函数名定义成$呀 和jquery的$冲突了
      

  3.   

    <script type="text/javascript">   
    //function $(el){return document.getElementById(el)}; 
    function response(obj)   
    {
    var oComment=obj.parentNode;
    oComment.appendChild($("#response").get(0)); 
    $("#response").get(0).style.display="block";
    } $(document).ready(function(){
    $("#add").click(function(){
    alert('fffffffffffffff');   
    })
    })</script>