2013-06-28 2 views
0

나는 필드를 편집하고 싶은 html 파일을 가지고있다.자바 스크립트 오류 : ReferenceError : 편집이 정의되지 않았습니다. 편집 (this);

<script language="javascript" type="text/javascript" src="serialize-0.2.min.js"> 

function edit(element){ 
    var tr = jQuery(element).parent().parent(); 
    if(!tr.hasClass("editing")) { 
      tr.addClass("editing"); 
      tr.find("DIV.td").each(function(){ 
        if(!jQuery(this).hasClass("action")){ 
          var value = jQuery(this).text(); 
          jQuery(this).text(""); 
          jQuery(this).append('<input type="text" value="'+value+'" />'); 
        } else { 
          jQuery(this).find("BUTTON").text("save"); 
        } 
      }); 
    } else { 
      tr.removeClass("editing"); 
      tr.find("DIV.td").each(function(){ 
        if(!jQuery(this).hasClass("action")){ 
          var value = jQuery(this).find("INPUT").val(); 
          jQuery(this).text(value); 
          jQuery(this).find("INPUT").remove(); 
        } else{ jQuery(this).find("BUTTON").text("edit"); 
        }}); } 
    }</script> 

아웃 내가 편집 버튼을 클릭하면, 그것은 참조 오류 편집을 보여주는 넣어 만드는 동안이 정의되지 않은 :

<body> 
    <div class= "table"> 
    <div class = "thead"> 
    <div class = "tr"> 

    <div class = "td">ID</div> 
    <div class = "td">GROUP NAME</div> 
    <div class = "td">GROUP DESCRIPTION</div> 
    <div class = "td">IS ACTIVE</div> 
    <div class = "td"></div> 
    <div class = "td"></div> 
    </div> 
    </div> 

<div class= "tbody"> 
<form class = "tr"> 
    <div class = "td">1</div> 
    <div class = "td">hello</div> 
    <div class = "td">hwryou</div> 
    <div class = "td">y</div> 
    <div class = "td action" ><button type="button "onclick="edit(this);">edit</button>  </div> 
    <form> 
    </div> 
    </div> 
    </body> 

다음 내 자바 스크립트 코드입니다 : 다음 내 HTML 코드입니다 그게 뭐야?

업데이트 :

내가, (가) 저장 버튼을 클릭에 변경된 내용이 어디서 업데이트 쿼리를 작성해야 할 수 있습니다 database.How에 저장해야합니다 타 요구 사항이 있습니까? 또한 삭제 버튼을 클릭하면 업데이트 명령을 실행해야합니다./

+0

여기에 공백이 없습니까? 'type = "버튼"onclick = "편집 (this);"? – elclanrs

+0

실제 코드에는 없습니다. 공간이 있습니다. –

답변

6

스크립트는 인라인 또는 외부가 될 수 있지만 둘 다일 수는 없습니다.

src 속성이 있으면 스크립트 노드의 텍스트 노드 하위가 무시됩니다.

인라인 및 외부 스크립트를 원하면 두 개의 스크립트 요소를 사용하십시오.

<script src="serialize-0.2.min.js"></script> 
<script> 
    function edit(element){ 
    // etc 
+0

나는 이렇게 사용했지만 오류를 보여줍니다 : ReferenceError : jQuery가 정의되어 있지 않습니다. [Break On This Error] \t var tr = jQuery (요소) .parent(). parent(); –

+1

jQuery를 호출하고 있습니다. '

-1
<script type="text/javascript" src="serialize-0.2.min.js"></script> 
<script type="text/javascript"> 
function edit(element){ 
    // Your Code 
} 
</script> 

이보십시오.

+0

만약 그것이 왜 받아 들일만한 해결책이 될지 설명했다면); – TecHunter

관련 문제