English 中文(简体)
Jquery 两个职能:产生增长问题
原标题:Jquery Two functions to create row problem

I had only one function to Add another row to the table id="tblOtherParties" and i worked fine, but when I added the second function to do the same with the table id="tblHospitalAction" I get the error of unterminated string constant, but I dont see why as its the same as the first function.

任何帮助都将受到高度赞赏。

我有以下职能:

<script type="text/javascript">
 var counter = 1;
  function createNewRow (text1,text2){
  var first = counter++;
  $( #tblOtherParties > tbody ).append( <tr><td>
   <input type="text" id="txtName_ +first+ " value=" +text1+ " />
   </td><td>
   <input type="text" id="txtRole_ +first+ " value=" +text2+ " />
   </td><td>
   <a class="deleteBtn"/>
   </td></tr> );
   }



 var counterHA = 1;
 function createNewRowHA (text1,text2){
  var first = counterHA++;
  $( #tblHospitalAction > tbody ).append( <tr>
   <td>
   <input type="text" id="txtH_ +first+ " value=" +text1+ " />
   </td>
   <td>
   <input type="text" id="txtA_ +first+ " value=" +text2+ " />
  </td><td><a class="deleteBtn"/></td>
   </tr> );
   }

  $(document).ready(function(){
   $(".deleteBtn").live("click", function(){
   $(this).closest( tr ).not( :only-child ).remove();
   });

   $( #btnAddOther ).click(function() {
     createNewRow(  ,  );
    });

   $( #btnAddHA ).click(function() {
     createNewRow(  ,  );
    });

});
</script>

下表

<div >
  <span style="float:left;padding-top:34px;"><b>Other involved parties</b></span>
  <table style="float:left;" id="tblOtherParties">
   <thead>
    <tr>
     <td class="title">Name</td>
     <td class="title">Role</td>
     <td><input type="button" id="btnAddOther" value="Add"/></td>
   </tr>
 </thead>
  <tbody>
   <tr>
    <td><input type="text" id="txtName_0" size="35"/></td>
    <td><input type="text" id="txtRole_0" size="35"/></td>
    <td><a class="deleteBtn" /></td>
  </tr>
  </tbody>
</table>
</div>

<div >
  <span style="float:left;><b>Other involved parties</b></span>
  <table style="float:left;" id="tblHospitalAction">
   <thead>
    <tr>
     <td class="title">Name</td>
     <td class="title">Role</td>
     <td><input type="button" id="btnAddHA" value="Add"/></td>
   </tr>
 </thead>
  <tbody>
   <tr>
    <td><input type="text" id="txtH_0" size="35"/></td>
    <td><input type="text" id="txtA_0" size="35"/></td>
    <td><a class="deleteBtn" /></td>
  </tr>
  </tbody>
</table>
</div>
最佳回答

你的扼杀是否跨越了你的实际来源中的多个界限,或者你只是为了在你看来显示目的而预示这些界限? 跨越多个界线的指令要么在每一行中终止,要么被压缩到下一个线,要么必须逃脱新的线性:

// Unterminated string constant on the first line
"this is a
 test string that spans multiple lines"

// Escaping the newline character
"this is a 
 test string that spans multiple lines"

// Concatenating each line:
"this is a "
+ "test string that spans multiple lines"

The biggest difference between the 2nd and the 3rd is that the 2nd will keep the newlines in the string, the third won t unless you add them manually using or . The downside to the second is that ALL other whitespace characters (spaces, tabs, etc) between the string delimiters are part of the string which makes it awkward to keep your code looking neat.

问题回答

如果 Java字面横跨多个线,每一行的结尾处都应有斜线。

http://www.codehouse.com/javascript/tips/string_multiline/





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签